From 850500f1616f870784bbd64a9a6df4f160cf76a9 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 5 Jul 2026 19:28:01 +0900 Subject: feat(exec-command): restore working directory via getInitialWorkingDirectory Downcasts the generic Application handle to the concrete shirabe Application to read getInitialWorkingDirectory(), so exec once again switches back to the directory it started in (e.g. after `composer global exec`), matching PHP's behavior. --- crates/shirabe/src/command/exec_command.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'crates/shirabe') diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs index a394ac4..659b8f7 100644 --- a/crates/shirabe/src/command/exec_command.rs +++ b/crates/shirabe/src/command/exec_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::console::input::InputOption; use crate::io::IOInterfaceImmutable; @@ -195,10 +196,16 @@ impl Command for ExecCommand { 0, ); - // TODO(phase-c): getApplication()->getInitialWorkingDirectory() needs the shared shirabe - // Application handle (deferred with the Application shared-ownership work). Until then the - // working-directory restore is skipped. - let initial_working_directory: Option = None; + let initial_working_directory = self.get_application().and_then(|application| { + let application = application.borrow(); + let app_dyn: &dyn shirabe_external_packages::symfony::console::application::Application = + &*application; + app_dyn + .as_any() + .downcast_ref::() + .expect("a Composer command's application is a shirabe Application") + .get_initial_working_directory() + }); if let Some(ref iwd) = initial_working_directory && getcwd().as_deref() != Some(iwd.as_str()) { -- cgit v1.3.1