diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-05 19:15:44 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-05 19:15:44 +0900 |
| commit | 3f7865faae3eb93c5c258320ebfb99855cbdeb97 (patch) | |
| tree | 396cf1cc611a0560da213bb4a7f9c7bb3a416a84 /crates/shirabe/src | |
| parent | 7fb4fbeee97dbce19276f28c21394b651832771c (diff) | |
| download | php-shirabe-3f7865faae3eb93c5c258320ebfb99855cbdeb97.tar.gz php-shirabe-3f7865faae3eb93c5c258320ebfb99855cbdeb97.tar.zst php-shirabe-3f7865faae3eb93c5c258320ebfb99855cbdeb97.zip | |
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.
Diffstat (limited to 'crates/shirabe/src')
| -rw-r--r-- | crates/shirabe/src/command/init_command.rs | 46 |
1 files changed, 34 insertions, 12 deletions
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<std::cell::RefCell<dyn OutputInterface>>) { - // 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<i64> { + 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::cell::RefCell<dyn InputInterface>> = + 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<std::cell::RefCell<dyn OutputInterface>>, ) { - // 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<i64> { + 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::cell::RefCell<dyn InputInterface>> = + 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<string, string|array<string>> $options |
