diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-22 01:29:48 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-22 01:43:48 +0900 |
| commit | 0b06f54103490e3ce5658e82bbc0119633e26cd8 (patch) | |
| tree | 687b075131d3679725e77e0931ff7c503a6c3034 /crates/shirabe/src/command/exec_command.rs | |
| parent | 2914770fba6b3cc03a68fae493f60470a41962ec (diff) | |
| download | php-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.tar.gz php-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.tar.zst php-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.zip | |
refactor(composer): unify Composer/PartialComposer via Rc handles
Model PHP's `Composer extends PartialComposer` as a PartialOrFullComposer
enum and merge partial_composer.rs into composer.rs. Introduce
ComposerHandle / PartialComposerHandle (plus their Weak variants) so the
graph can be shared, and build it at once with Rc::new_cyclic in the
factory to resolve the back-reference cycles.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/exec_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/exec_command.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs index 198bdb1..68e2d0f 100644 --- a/crates/shirabe/src/command/exec_command.rs +++ b/crates/shirabe/src/command/exec_command.rs @@ -6,7 +6,6 @@ use shirabe_external_packages::symfony::component::console::output::OutputInterf use shirabe_php_shim::{PhpMixed, RuntimeException, basename, chdir, getcwd, glob}; use crate::command::{BaseCommand, BaseCommandData, HasBaseCommandData}; -use crate::composer::Composer; use crate::console::input::InputArgument; use crate::console::input::InputOption; use crate::io::IOInterface; @@ -80,15 +79,15 @@ impl ExecCommand { input: &dyn InputInterface, _output: &dyn OutputInterface, ) -> Result<i64> { - let mut composer = self.require_composer(None, None)?; + let composer = self.require_composer(None, None)?; if input.get_option("list").as_bool().unwrap_or(false) || input.get_argument("binary").as_string_opt().is_none() { let bins = self.get_binaries(true)?; if bins.is_empty() { - let bin_dir = composer - .get_config_mut() + let bin_dir = crate::command::composer_full_mut(&composer) + .get_config() .borrow_mut() .get("bin-dir") .as_string() @@ -119,9 +118,11 @@ impl ExecCommand { .unwrap_or("") .to_string(); - let dispatcher = composer.get_event_dispatcher(); + let dispatcher = crate::command::composer_full(&composer) + .get_event_dispatcher() + .clone(); // TODO(phase-b): add_listener takes a Callable; wiring binary as callable not yet ported - let _ = (dispatcher, &binary); + let _ = &binary; let initial_working_directory = self.get_application()?.get_initial_working_directory(); if let Some(ref iwd) = initial_working_directory { @@ -152,16 +153,17 @@ impl ExecCommand { } fn get_binaries(&mut self, for_display: bool) -> Result<Vec<String>> { - let mut composer = self.require_composer(None, None)?; - let bin_dir = composer - .get_config_mut() + let composer = self.require_composer(None, None)?; + let composer_ref = crate::command::composer_full_mut(&composer); + let bin_dir = composer_ref + .get_config() .borrow_mut() .get("bin-dir") .as_string() .unwrap_or("") .to_string(); let bins = glob(&format!("{}/*", bin_dir)); - let local_bins_raw: Vec<String> = composer.get_package().get_binaries(); + let local_bins_raw: Vec<String> = composer_ref.get_package().get_binaries(); let local_bins: Vec<String> = if for_display { local_bins_raw .into_iter() |
