From e87d37a294a4c754585309d391d793a2c9a1287e Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 24 Jun 2026 04:16:08 +0900 Subject: feat(console): implement application description for `list` Replace the todo!() in TextDescriptor::describe_application with a real option-only InputDefinition built via InputDefinition::from_options, which shares InputOption behind Rc instead of reconstructing by value. Drop the now-unused Command::clone_box and switch the descriptors to borrow the shared commands directly. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/symfony/console/input/input_definition.rs | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs') diff --git a/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs b/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs index 390f416..911e287 100644 --- a/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs +++ b/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs @@ -46,6 +46,26 @@ impl InputDefinition { Ok(input_definition) } + /// Builds an option-only definition that shares the given options by + /// reference, mirroring `new InputDefinition($definition->getOptions())`. + /// `InputOption` is not `Clone` and lives behind `Rc`, so the options are + /// reused rather than reconstructed by value. + pub fn from_options(options: Vec>) -> anyhow::Result { + let mut input_definition = InputDefinition { + arguments: IndexMap::new(), + required_count: 0, + last_array_argument: None, + last_optional_argument: None, + options: IndexMap::new(), + negations: IndexMap::new(), + shortcuts: IndexMap::new(), + }; + for option in options { + input_definition.add_option_rc(option)?; + } + Ok(input_definition) + } + /// Sets the definition of the input. pub fn set_definition(&mut self, definition: Vec) -> anyhow::Result<()> { let mut arguments = vec![]; @@ -230,8 +250,12 @@ impl InputDefinition { } pub fn add_option(&mut self, option: InputOption) -> anyhow::Result<()> { - let option = Rc::new(option); + self.add_option_rc(Rc::new(option)) + } + /// Adds an option that is already shared behind `Rc`, mirroring PHP passing + /// `InputOption` objects by reference. + pub fn add_option_rc(&mut self, option: Rc) -> anyhow::Result<()> { if let Some(existing) = self.options.get(option.get_name()) && !option.equals(existing) { -- cgit v1.3.1