diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-05 19:28:01 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-05 19:28:01 +0900 |
| commit | 850500f1616f870784bbd64a9a6df4f160cf76a9 (patch) | |
| tree | 74328d2748f5318f10d7f9e80e4ba6308728506b /crates/shirabe | |
| parent | 325bb3ca3789843304424c7d552d0d3bb8d39ea2 (diff) | |
| download | php-shirabe-850500f1616f870784bbd64a9a6df4f160cf76a9.tar.gz php-shirabe-850500f1616f870784bbd64a9a6df4f160cf76a9.tar.zst php-shirabe-850500f1616f870784bbd64a9a6df4f160cf76a9.zip | |
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.
Diffstat (limited to 'crates/shirabe')
| -rw-r--r-- | crates/shirabe/src/command/exec_command.rs | 15 |
1 files changed, 11 insertions, 4 deletions
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<String> = 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::<Application>() + .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()) { |
