diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-12 01:01:35 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-12 01:01:43 +0900 |
| commit | 1e44f5723e4c0e0903d00a61f254901e612fe5e1 (patch) | |
| tree | 9c2e1eec364bbf6418a4072ee7767b04c3df0297 /crates/shirabe/src/command/base_config_command.rs | |
| parent | ddf0a624145b618c05c2ee47414545b99b685f37 (diff) | |
| download | php-shirabe-1e44f5723e4c0e0903d00a61f254901e612fe5e1.tar.gz php-shirabe-1e44f5723e4c0e0903d00a61f254901e612fe5e1.tar.zst php-shirabe-1e44f5723e4c0e0903d00a61f254901e612fe5e1.zip | |
feat(symfony-console): port Symfony Console and make the workspace compile
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/base_config_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/base_config_command.rs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/crates/shirabe/src/command/base_config_command.rs b/crates/shirabe/src/command/base_config_command.rs index bfdd33a..4f6fd59 100644 --- a/crates/shirabe/src/command/base_config_command.rs +++ b/crates/shirabe/src/command/base_config_command.rs @@ -31,10 +31,10 @@ pub trait BaseConfigCommand: BaseCommand { if input .borrow() - .get_option("global") + .get_option("global")? .as_bool() .unwrap_or(false) - && !input.borrow().get_option("file").is_null() + && !input.borrow().get_option("file")?.is_null() { return Err(anyhow::anyhow!("--file and --global can not be combined")); } @@ -48,7 +48,7 @@ pub trait BaseConfigCommand: BaseCommand { // When using --global flag, set baseDir to home directory for correct absolute path resolution if input .borrow() - .get_option("global") + .get_option("global")? .as_bool() .unwrap_or(false) { @@ -56,7 +56,7 @@ pub trait BaseConfigCommand: BaseCommand { config_rc.borrow_mut().set_base_dir(Some(home)); } - let config_file = self.get_composer_config_file(input.clone(), &*config_rc.borrow()); + let config_file = self.get_composer_config_file(input.clone(), &*config_rc.borrow())?; // Create global composer.json if invoked using `composer global [config-cmd]` if (config_file == "composer.json" || config_file == "./composer.json") @@ -77,7 +77,7 @@ pub trait BaseConfigCommand: BaseCommand { // Initialize the global file if it's not there, ignoring any warnings or notices if input .borrow() - .get_option("global") + .get_option("global")? .as_bool() .unwrap_or(false) && !self.config_file().unwrap().borrow().exists() @@ -116,21 +116,21 @@ pub trait BaseConfigCommand: BaseCommand { &self, input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, config: &Config, - ) -> String { + ) -> anyhow::Result<String> { if input .borrow() - .get_option("global") + .get_option("global")? .as_bool() .unwrap_or(false) { - format!("{}/config.json", config.get("home")) + Ok(format!("{}/config.json", config.get("home"))) } else { - input + Ok(input .borrow() - .get_option("file") + .get_option("file")? .as_string() .map(|s| s.to_string()) - .unwrap_or_else(|| Factory::get_composer_file().unwrap_or_default()) + .unwrap_or_else(|| Factory::get_composer_file().unwrap_or_default())) } } @@ -140,21 +140,21 @@ pub trait BaseConfigCommand: BaseCommand { &self, input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, config: &Config, - ) -> String { + ) -> anyhow::Result<String> { if input .borrow() - .get_option("global") + .get_option("global")? .as_bool() .unwrap_or(false) { - format!("{}/auth.json", config.get("home")) + Ok(format!("{}/auth.json", config.get("home"))) } else { - let composer_config = self.get_composer_config_file(input, config); + let composer_config = self.get_composer_config_file(input, config)?; let parent = std::path::Path::new(&composer_config) .parent() .map(|p| p.to_string_lossy().to_string()) .unwrap_or_default(); - format!("{}/auth.json", parent) + Ok(format!("{}/auth.json", parent)) } } } |
