From 7f24ec418432a66da451b7c83042185dca42da9c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 5 Jul 2026 19:28:06 +0900 Subject: 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. --- crates/shirabe/src/command/run_script_command.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'crates') 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::().is_some() + || e.downcast_ref::().is_some() => {} + Err(e) => return Err(e), + } + } result.push((name, description)); } -- cgit v1.3.1