From 3f7865faae3eb93c5c258320ebfb99855cbdeb97 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 5 Jul 2026 19:15:44 +0900 Subject: feat(init-command): wire update/dump-autoload sub-command dispatch Application::find and BaseCommand::reset_composer are now available, so the deferred update_dependencies/run_dump_autoload_command stubs can find, reset, and run the sibling command directly, matching InitCommand's PHP behavior. --- crates/shirabe/src/command/init_command.rs | 46 ++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'crates') diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index 856cc78..4a2e9a3 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -1112,24 +1112,46 @@ impl InitCommand { } fn update_dependencies(&self, output: std::rc::Rc>) { - // PHP: try { $this->getApplication()->find('update')->run(new ArrayInput([]), $output); } - // catch (\Exception $e) { $this->getIO()->writeError('Could not update dependencies...'); } - // TODO(phase-c): needs the shared shirabe Application handle and the typed command registry - // (deferred with the Application shared-ownership work). Until then this is a no-op. - let _ = ArrayInput::new(vec![], None); - let _ = output; + let result = (|| -> anyhow::Result { + let application = self + .get_application() + .expect("a Composer command's application is always set"); + let update_command = application.borrow_mut().find("update")?; + self.reset_composer()?; + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(ArrayInput::new(vec![], None)?)); + let command = update_command.borrow(); + command.run(input, output) + })(); + + if result.is_err() { + self.get_io().borrow().write_error( + "Could not update dependencies. Run `composer update` to see more information.", + ); + } } fn run_dump_autoload_command( &self, output: std::rc::Rc>, ) { - // PHP: try { $this->getApplication()->find('dump-autoload')->run(new ArrayInput([]), $output); } - // catch (\Exception $e) { $this->getIO()->writeError('Could not run dump-autoload.'); } - // TODO(phase-c): same deferral as update_dependencies — needs the shared shirabe - // Application handle and the typed command registry. - let _ = ArrayInput::new(vec![], None); - let _ = output; + let result = (|| -> anyhow::Result { + let application = self + .get_application() + .expect("a Composer command's application is always set"); + let command = application.borrow_mut().find("dump-autoload")?; + self.reset_composer()?; + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(ArrayInput::new(vec![], None)?)); + let command = command.borrow(); + command.run(input, output) + })(); + + if result.is_err() { + self.get_io() + .borrow() + .write_error("Could not run dump-autoload."); + } } /// @param array> $options -- cgit v1.3.1