diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-23 01:41:33 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-23 01:41:33 +0900 |
| commit | 421d98d9a52dd036acd5632f9049f4503c9add18 (patch) | |
| tree | 578d4bc15a7cb01a591393df85d0b9cdfd7d6ea2 /crates/shirabe/src/console/application.rs | |
| parent | 894764ecb04f9c456b9ebda77d155bf6128e2175 (diff) | |
| download | php-shirabe-421d98d9a52dd036acd5632f9049f4503c9add18.tar.gz php-shirabe-421d98d9a52dd036acd5632f9049f4503c9add18.tar.zst php-shirabe-421d98d9a52dd036acd5632f9049f4503c9add18.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/console/application.rs')
| -rw-r--r-- | crates/shirabe/src/console/application.rs | 12 |
1 files changed, 1 insertions, 11 deletions
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<std::cell::RefCell<dyn HelperInterface>>, - > = 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. |
