diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-05 19:28:06 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-05 19:28:06 +0900 |
| commit | 7f24ec418432a66da451b7c83042185dca42da9c (patch) | |
| tree | 4a5b0a0b852700cef91da565189fd994aecc9da6 | |
| parent | 850500f1616f870784bbd64a9a6df4f160cf76a9 (diff) | |
| download | php-shirabe-7f24ec418432a66da451b7c83042185dca42da9c.tar.gz php-shirabe-7f24ec418432a66da451b7c83042185dca42da9c.tar.zst php-shirabe-7f24ec418432a66da451b7c83042185dca42da9c.zip | |
feat(run-script-command): resolve script command descriptions via find()
Application::find is now available, so getScripts can look up each
script's associated command and read its description, ignoring
CommandNotFoundException/NamespaceNotFoundException the same way the
PHP code does for scripts with no associated command.
| -rw-r--r-- | crates/shirabe/src/command/run_script_command.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs index fdfc4c0..7fc9703 100644 --- a/crates/shirabe/src/command/run_script_command.rs +++ b/crates/shirabe/src/command/run_script_command.rs @@ -12,6 +12,8 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use indexmap::IndexMap; use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::exception::CommandNotFoundException; +use shirabe_external_packages::symfony::console::exception::namespace_not_found_exception::NamespaceNotFoundException; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::PhpMixed; @@ -92,15 +94,16 @@ impl RunScriptCommand { let mut result: Vec<(String, String)> = vec![]; for (name, _script) in scripts { - // PHP: $cmd = $this->getApplication()->find($name); $description = $cmd->getDescription(); - // TODO(phase-c): Application::find returns PhpMixed (the Symfony command registry is a - // todo!() stub) and get_application() is itself deferred, so the resolved command's - // getDescription() cannot be read; the description stays empty until the typed command - // registry is modelled. - // get_application() is deferred (returns the Symfony `dyn Application` back-reference, - // not the shirabe Application with find()); the description stays empty until the - // shared Application handle and typed command registry are modelled. - let description = String::new(); + let mut description = String::new(); + if let Some(application) = self.get_application() { + match application.borrow_mut().find(&name) { + Ok(cmd) => description = cmd.borrow().get_description(), + Err(e) + if e.downcast_ref::<CommandNotFoundException>().is_some() + || e.downcast_ref::<NamespaceNotFoundException>().is_some() => {} + Err(e) => return Err(e), + } + } result.push((name, description)); } |
