From d5b313f388d424e60ae33ae58c1a65a65b24b8f1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 6 Jun 2026 18:04:45 +0900 Subject: refactor(command): share Input/OutputInterface via Rc Convert InputInterface and OutputInterface parameters from &dyn/&mut dyn references to Rc> shared ownership across the command, console, and IO layers, matching the Phase C shared-ownership approach already used for IOInterface. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/command/audit_command.rs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/command/audit_command.rs') diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs index a28c344..f739029 100644 --- a/crates/shirabe/src/command/audit_command.rs +++ b/crates/shirabe/src/command/audit_command.rs @@ -48,11 +48,11 @@ impl AuditCommand { pub fn execute( &mut self, - input: &dyn InputInterface, - _output: &dyn OutputInterface, + input: std::rc::Rc>, + _output: std::rc::Rc>, ) -> Result { let composer = self.require_composer(None, None)?; - let packages = self.get_packages(&composer, input)?; + let packages = self.get_packages(&composer, input.clone())?; if packages.is_empty() { self.get_io().write_error("No packages - skipping audit."); @@ -84,6 +84,7 @@ impl AuditCommand { )?; let abandoned = input + .borrow() .get_option("abandoned") .as_string() .map(|s| s.to_string()); @@ -113,10 +114,11 @@ impl AuditCommand { let abandoned = abandoned.unwrap_or_else(|| audit_config.audit_abandoned.clone()); let ignore_severities = array_merge( - array_fill_keys(input.get_option("ignore-severity"), PhpMixed::Null), + array_fill_keys(input.borrow().get_option("ignore-severity"), PhpMixed::Null), PhpMixed::from(audit_config.ignore_severity_for_audit.clone()), ); let ignore_unreachable = input + .borrow() .get_option("ignore-unreachable") .as_bool() .unwrap_or(false) @@ -144,10 +146,15 @@ impl AuditCommand { fn get_packages( &self, composer: &PartialComposerHandle, - input: &dyn InputInterface, + input: std::rc::Rc>, ) -> Result> { let mut composer = crate::command::composer_full_mut(composer); - if input.get_option("locked").as_bool().unwrap_or(false) { + if input + .borrow() + .get_option("locked") + .as_bool() + .unwrap_or(false) + { let locker = composer.get_locker().clone(); let mut locker = locker.borrow_mut(); if !locker.is_locked() { @@ -156,8 +163,13 @@ impl AuditCommand { code: 0, }.into()); } - let locked_repo = locker - .get_locked_repository(!input.get_option("no-dev").as_bool().unwrap_or(false))?; + let locked_repo = locker.get_locked_repository( + !input + .borrow() + .get_option("no-dev") + .as_bool() + .unwrap_or(false), + )?; return locked_repo.borrow_mut().get_canonical_packages(); } -- cgit v1.3.1