From 325bb3ca3789843304424c7d552d0d3bb8d39ea2 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 5 Jul 2026 19:27:56 +0900 Subject: feat(global-command): wire resetComposer and Application::run proxying Application::find/reset_composer and the shared ApplicationHandle are now available, so GlobalCommand can reset the composer instance before building the sub-command input and proxy execution through the full Application::run dispatch, matching PHP's behavior. Un-ignores the tests that only depended on this wiring, and re-points the remaining ignores at their real (unrelated) blockers. --- crates/shirabe/src/command/global_command.rs | 23 ++++++++++++++++------ .../shirabe/tests/command/global_command_test.rs | 8 ++------ 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'crates') diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs index 27331a7..b0a3542 100644 --- a/crates/shirabe/src/command/global_command.rs +++ b/crates/shirabe/src/command/global_command.rs @@ -3,6 +3,7 @@ use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; +use crate::console::Application; use crate::console::input::InputArgument; use crate::factory::Factory; use crate::util::Filesystem; @@ -106,8 +107,7 @@ impl GlobalCommand { &Self::input_to_string(&*input.borrow())?, 1, ); - // TODO(phase-c): getApplication()->resetComposer() needs the shared shirabe Application - // handle (deferred with the Application shared-ownership work). + self.reset_composer()?; StringInput::new(&new_input_str) } @@ -171,10 +171,21 @@ impl Command for GlobalCommand { } let sub_input = self.prepare_subcommand_input(input, false)?; - // TODO(phase-c): proxying to Application::run needs the shared shirabe Application handle - // (deferred with the Application shared-ownership work and command registration). - let _ = (sub_input, output); - todo!("global command proxy run pending shared Application handle") + let sub_input: Rc> = Rc::new(RefCell::new(sub_input)); + + let application = { + let application = self + .get_application() + .expect("a proxy command is always attached to its application"); + let application = application.borrow(); + application + .as_any() + .downcast_ref::() + .expect("shirabe always installs its own Application") + .shared() + }; + + Ok(application.run(Some(sub_input), Some(output))? as i64) } fn initialize( diff --git a/crates/shirabe/tests/command/global_command_test.rs b/crates/shirabe/tests/command/global_command_test.rs index 4d99613..5f0efd0 100644 --- a/crates/shirabe/tests/command/global_command_test.rs +++ b/crates/shirabe/tests/command/global_command_test.rs @@ -31,7 +31,7 @@ fn chdir_unique_tmp_directory() -> TempDir { #[test] #[serial] -#[ignore = "GlobalCommand::run proxies to Application::run via todo!() at crates/shirabe/src/command/global_command.rs:190 (pending shared Application handle)"] +#[ignore = "runs a composer.json script, which Application::do_run registers as a reflection-instantiated command; that registration path is todo!() at crates/shirabe/src/console/application.rs:2461 (plugin: register reflection-instantiated command on Application::add)"] fn test_global() { let _env_guard = EnvGuard; @@ -120,7 +120,6 @@ fn test_cannot_create_home() { #[test] #[serial] -#[ignore = "GlobalCommand::run proxies to Application::run via todo!() at crates/shirabe/src/command/global_command.rs:190 (pending shared Application handle)"] fn test_global_show() { let _env_guard = EnvGuard; @@ -171,7 +170,6 @@ fn test_global_show() { #[test] #[serial] -#[ignore = "GlobalCommand::run proxies to Application::run via todo!() at crates/shirabe/src/command/global_command.rs:190 (pending shared Application handle)"] fn test_global_show_without_packages() { let _env_guard = EnvGuard; @@ -203,7 +201,7 @@ fn test_global_show_without_packages() { #[test] #[serial] -#[ignore = "GlobalCommand::run proxies to Application::run via todo!() at crates/shirabe/src/command/global_command.rs:190 (pending shared Application handle)"] +#[ignore = "installs a package via the global command's require sub-dispatch, which panics inside the event dispatcher: \"Subscriber ?::? for event pre-operations-exec is not callable\""] fn test_global_require() { let _env_guard = EnvGuard; @@ -262,7 +260,6 @@ fn test_global_require() { #[test] #[serial] -#[ignore = "GlobalCommand::run proxies to Application::run via todo!() at crates/shirabe/src/command/global_command.rs:190 (pending shared Application handle)"] fn test_global_update() { let _env_guard = EnvGuard; @@ -313,7 +310,6 @@ fn test_global_update() { #[test] #[serial] -#[ignore = "GlobalCommand::run proxies to Application::run via todo!() at crates/shirabe/src/command/global_command.rs:190 (pending shared Application handle)"] fn test_global_changes_directory() { let _env_guard = EnvGuard; -- cgit v1.3.1