diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-24 04:16:08 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-24 04:16:08 +0900 |
| commit | e87d37a294a4c754585309d391d793a2c9a1287e (patch) | |
| tree | cc9ebf30f30355be0545a02462162c534516ca8b /crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs | |
| parent | f1af14b1cc503ac20f56a79a96c7780d02bdfe75 (diff) | |
| download | php-shirabe-e87d37a294a4c754585309d391d793a2c9a1287e.tar.gz php-shirabe-e87d37a294a4c754585309d391d793a2c9a1287e.tar.zst php-shirabe-e87d37a294a4c754585309d391d793a2c9a1287e.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs')
| -rw-r--r-- | crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs | 26 |
1 files changed, 25 insertions, 1 deletions
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<Rc<InputOption>>) -> anyhow::Result<Self> { + 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<DefinitionItem>) -> 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<InputOption>) -> anyhow::Result<()> { if let Some(existing) = self.options.get(option.get_name()) && !option.equals(existing) { |
