From 421d98d9a52dd036acd5632f9049f4503c9add18 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 23 Jun 2026 01:41:33 +0900 Subject: refactor(io): hold QuestionHelper directly in ConsoleIO instead of HelperSet Every ConsoleIO construction site only ever registers a single QuestionHelper (production) or none (tests), and routing asks through HelperSet::get('question') loses the concrete type, forcing a downcast back to QuestionHelper. Receive the QuestionHelper in the constructor and hold it directly (in a RefCell, since QuestionHelper::ask takes &mut self while the IOInterfaceImmutable ask methods are &self), dropping the HelperSet field and the throwaway HelperSet built at each call site. Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/src/console/application.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'crates/shirabe/src/console') diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 5dd2eeb..c3287e7 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -1973,20 +1973,10 @@ impl ApplicationHandle { input.borrow_mut().set_interactive(false); } - let mut helpers: IndexMap< - HelperSetKey, - std::rc::Rc>, - > = IndexMap::new(); - helpers.insert( - HelperSetKey::Int(0), - std::rc::Rc::new(std::cell::RefCell::new(QuestionHelper::default())), - ); - let helper_set = std::rc::Rc::new(std::cell::RefCell::new(HelperSet::default())); - HelperSet::new(&helper_set, helpers); application.borrow_mut().io = std::rc::Rc::new(std::cell::RefCell::new(ConsoleIO::new( input.clone(), output.clone(), - helper_set.borrow().clone(), + QuestionHelper::default(), ))); // Cache the IO so the rest of the flow does not re-borrow the application; command callbacks // (e.g. mergeApplicationDefinition) need the application's RefCell free. -- cgit v1.3.1