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/global_command.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'crates/shirabe/src/command/global_command.rs') diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs index a3d5a78..e5d06b7 100644 --- a/crates/shirabe/src/command/global_command.rs +++ b/crates/shirabe/src/command/global_command.rs @@ -56,8 +56,12 @@ impl GlobalCommand { ); } - pub fn run(&mut self, input: &dyn InputInterface, output: &dyn OutputInterface) -> Result { - let tokens = Preg::split(r"{\s+}", &input.to_input_string())?; + pub fn run( + &mut self, + input: std::rc::Rc>, + output: std::rc::Rc>, + ) -> Result { + let tokens = Preg::split(r"{\s+}", &input.borrow().to_input_string())?; let mut args: Vec = vec![]; for token in &tokens { if !token.is_empty() && !token.starts_with('-') { @@ -76,12 +80,15 @@ impl GlobalCommand { let mut sub_input = self.prepare_subcommand_input(input, false)?; let mut app = self.get_application()?; let _ = output; - Ok(app.run(Some(&mut sub_input), None)?) + Ok(app.run( + Some(std::rc::Rc::new(std::cell::RefCell::new(sub_input))), + None, + )?) } fn prepare_subcommand_input( &mut self, - input: &dyn InputInterface, + input: std::rc::Rc>, quiet: bool, ) -> Result { if Platform::get_env("COMPOSER").is_some() { @@ -118,7 +125,7 @@ impl GlobalCommand { let new_input_str = Preg::replace4( r"{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}", "", - &input.to_input_string(), + &input.borrow().to_input_string(), 1, )?; self.get_application()?.reset_composer(); -- cgit v1.3.1