From ffd3e239a56172d2a336fb4d6253c01f6b1a0100 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 22 Jun 2026 04:38:26 +0900 Subject: refactor(console): introduce ApplicationHandle shared-ownership newtype Collapse the dual Application API (static methods taking `&Rc>` plus `&mut self` bridges via `shared()`) into a single handle type `ApplicationHandle(Rc>)`, mirroring the Composer handle pattern. Methods that invoke command callbacks (add, run, do_run, base_run, base_do_run, do_run_command, add_commands, init) move to `impl ApplicationHandle` with short-scoped borrows; data-only methods and `impl BaseApplication` stay on `Application`. `shared()` now returns the handle, and `new_shared`/`init_shared` fold into `ApplicationHandle::new`/`init`. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/tests/application_test.rs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'crates/shirabe/tests') diff --git a/crates/shirabe/tests/application_test.rs b/crates/shirabe/tests/application_test.rs index dddf8de..7a2a751 100644 --- a/crates/shirabe/tests/application_test.rs +++ b/crates/shirabe/tests/application_test.rs @@ -9,7 +9,7 @@ use std::rc::Rc; use shirabe::command::about_command::AboutCommand; use shirabe::command::self_update_command::SelfUpdateCommand; -use shirabe::console::application::Application; +use shirabe::console::application::ApplicationHandle; use shirabe::util::platform::Platform; use shirabe_external_packages::symfony::console::command::Command; use shirabe_external_packages::symfony::console::input::array_input::ArrayInput; @@ -54,12 +54,9 @@ fn test_dev_warning_suppressed_for_self_update() { return; } - let application = Rc::new(RefCell::new(Application::new( - "Composer".to_string(), - "".to_string(), - ))); + let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); let command: Rc> = Rc::new(RefCell::new(SelfUpdateCommand::new())); - application.borrow_mut().add(command).unwrap(); + application.add(command).unwrap(); let output = Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); let input: Rc> = Rc::new(RefCell::new( @@ -70,7 +67,7 @@ fn test_dev_warning_suppressed_for_self_update() { .unwrap(), )); let output_trait: Rc> = output.clone(); - Application::do_run(&application, input, output_trait).unwrap(); + application.do_run(input, output_trait).unwrap(); assert_eq!( "This instance of Composer does not have the self-update command.\n\ @@ -85,12 +82,9 @@ fn test_process_isolation_works_multiple_times() { let _tear_down = TearDown; set_up(); - let application = Rc::new(RefCell::new(Application::new( - "Composer".to_string(), - "".to_string(), - ))); + let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); let command: Rc> = Rc::new(RefCell::new(AboutCommand::new())); - application.borrow_mut().add(command).unwrap(); + application.add(command).unwrap(); let input1: Rc> = Rc::new(RefCell::new( ArrayInput::new( @@ -101,10 +95,7 @@ fn test_process_isolation_works_multiple_times() { )); let output1: Rc> = Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); - assert_eq!( - 0, - Application::do_run(&application, input1, output1).unwrap() - ); + assert_eq!(0, application.do_run(input1, output1).unwrap()); let input2: Rc> = Rc::new(RefCell::new( ArrayInput::new( @@ -115,10 +106,7 @@ fn test_process_isolation_works_multiple_times() { )); let output2: Rc> = Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); - assert_eq!( - 0, - Application::do_run(&application, input2, output2).unwrap() - ); + assert_eq!(0, application.do_run(input2, output2).unwrap()); } #[ignore = "Application::set_auto_exit / set_catch_errors and the initTempComposer test helper do not exist"] -- cgit v1.3.1