diff options
Diffstat (limited to 'crates/shirabe/src/command')
| -rw-r--r-- | crates/shirabe/src/command/check_platform_reqs_command.rs | 8 | ||||
| -rw-r--r-- | crates/shirabe/src/command/config_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/fund_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/init_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/licenses_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/repository_command.rs | 15 | ||||
| -rw-r--r-- | crates/shirabe/src/command/search_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/show_command.rs | 8 |
8 files changed, 24 insertions, 17 deletions
diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs index 088c9407..903e0c4c 100644 --- a/crates/shirabe/src/command/check_platform_reqs_command.rs +++ b/crates/shirabe/src/command/check_platform_reqs_command.rs @@ -59,7 +59,7 @@ impl CheckPlatformReqsCommand { output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, results: &[CheckResult], format: &str, - ) { + ) -> anyhow::Result<()> { let io = self.get_io(); if format == "json" { @@ -117,7 +117,7 @@ impl CheckPlatformReqsCommand { }) .collect(); - io.write(&JsonFile::encode(&PhpMixed::List(rows))); + io.write(&JsonFile::encode(&PhpMixed::List(rows))?); } else { let rows: Vec<PhpMixed> = results .iter() @@ -151,6 +151,8 @@ impl CheckPlatformReqsCommand { self.render_table(rows, output); } + + Ok(()) } } @@ -396,7 +398,7 @@ impl Command for CheckPlatformReqsCommand { .as_string() .unwrap_or("text") .to_string(); - self.print_table(_output, &results, &format); + self.print_table(_output, &results, &format)?; Ok(exit_code) } diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index 0b22757a..7e8b82e9 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -497,7 +497,7 @@ impl Command for ConfigCommand { pretty_print: false, ..Default::default() }, - ) + )? } else { value.as_string().unwrap_or("").to_string() }; diff --git a/crates/shirabe/src/command/fund_command.rs b/crates/shirabe/src/command/fund_command.rs index bf5e281a..8ea566dc 100644 --- a/crates/shirabe/src/command/fund_command.rs +++ b/crates/shirabe/src/command/fund_command.rs @@ -211,7 +211,7 @@ impl Command for FundCommand { io.write("Thank you!"); } else if format == "json" { let fundings_mixed: PhpMixed = fundings.clone().into(); - io.write(&JsonFile::encode(&fundings_mixed)); + io.write(&JsonFile::encode(&fundings_mixed)?); } else { io.write("No funding links were found in your package dependencies. This doesn't mean they don't need your support!"); } diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index ec3f38b5..6923f768 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -290,7 +290,7 @@ impl Command for InitCommand { let file_obj = JsonFile::new(Factory::get_composer_file()?, None, None)?; let options_for_encode: IndexMap<String, PhpMixed> = options.clone().into_iter().collect(); - let json = JsonFile::encode(&PhpMixed::Array(options_for_encode.clone())); + let json = JsonFile::encode(&PhpMixed::Array(options_for_encode.clone()))?; if input.borrow().is_interactive() { io.write_error3(&format!("\n{}\n", json), true, io_interface::NORMAL); diff --git a/crates/shirabe/src/command/licenses_command.rs b/crates/shirabe/src/command/licenses_command.rs index 002bce89..41e9ba90 100644 --- a/crates/shirabe/src/command/licenses_command.rs +++ b/crates/shirabe/src/command/licenses_command.rs @@ -273,7 +273,7 @@ impl Command for LicensesCommand { output_map.insert("dependencies".to_string(), PhpMixed::Array(dependencies)); io.write(&JsonFile::encode(&PhpMixed::Array( output_map.into_iter().collect(), - ))); + ))?); } "summary" => { let mut used_licenses: IndexMap<String, i64> = IndexMap::new(); diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs index 31d2de3f..d23e114c 100644 --- a/crates/shirabe/src/command/repository_command.rs +++ b/crates/shirabe/src/command/repository_command.rs @@ -50,7 +50,7 @@ impl RepositoryCommand { command } - fn list_repositories(&self, mut repos: IndexMap<String, PhpMixed>) { + fn list_repositories(&self, mut repos: IndexMap<String, PhpMixed>) -> anyhow::Result<()> { let io = self.get_io(); let mut packagist_present = false; @@ -84,7 +84,7 @@ impl RepositoryCommand { if repos.is_empty() { io.write("No repositories configured"); - return; + return Ok(()); } for (key, repo) in &repos { @@ -111,14 +111,19 @@ impl RepositoryCommand { .get("type") .and_then(|v| v.as_string()) .unwrap_or("unknown"); - let url = repo_map + let url = match repo_map .get("url") .and_then(|v| v.as_string()) .map(|s| s.to_string()) - .unwrap_or_else(|| JsonFile::encode(repo)); + { + Some(url) => url, + None => JsonFile::encode(repo)?, + }; io.write(&format!("[{}] <info>{}</info> {}", name, r#type, url)); } } + + Ok(()) } /// PHP: private function suggestTypeForAdd(): \Closure (a static closure — `this` unused) @@ -352,7 +357,7 @@ impl Command for RepositoryCommand { match action.as_str() { "list" | "ls" | "show" => { - self.list_repositories(repos); + self.list_repositories(repos)?; Ok(0) } "add" => { diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs index 2e0f95da..b0eabf80 100644 --- a/crates/shirabe/src/command/search_command.rs +++ b/crates/shirabe/src/command/search_command.rs @@ -293,7 +293,7 @@ impl Command for SearchCommand { PhpMixed::Array(entry) }) .collect(); - io.write(&JsonFile::encode(&PhpMixed::List(rows))); + io.write(&JsonFile::encode(&PhpMixed::List(rows))?); } Ok(0) diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index 4cc0c204..a3bf7157 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -698,7 +698,7 @@ impl Command for ShowCommand { ); self.get_io().write(&JsonFile::encode(&PhpMixed::Array( wrapper.into_iter().collect(), - ))); + ))?); } else { self.display_package_tree(vec![array_tree]); } @@ -829,7 +829,7 @@ impl Command for ShowCommand { ); self.get_io().write(&JsonFile::encode(&PhpMixed::Array( wrapper.into_iter().collect(), - ))); + ))?); } else { self.display_package_tree(array_tree); } @@ -1289,7 +1289,7 @@ impl Command for ShowCommand { let io = self.get_io(); io.write(&JsonFile::encode(&PhpMixed::Array( json_map.into_iter().collect(), - ))); + ))?); } else { if input.borrow().get_option("latest")?.as_bool() == Some(true) && view_data.values().any(|v| !v.is_empty()) @@ -2222,7 +2222,7 @@ impl ShowCommand { self.get_io().write(&JsonFile::encode(&PhpMixed::Array( json.into_iter().collect(), - ))); + ))?); Ok(()) } |
