From 6051927c8fa32cfffa102d2a170c5a6cf747a1b9 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 9 Aug 2026 11:19:03 +0900 Subject: refactor(symfony-console): extract symfony/console into the shirabe-symfony-console crate Move `Symfony\Component\Console` out of shirabe-external-packages and into its own crate, so the path is `shirabe_symfony_console::application::Application` instead of `shirabe_external_packages::symfony::console::application::Application`. The `delegate_to_inner!` and `delegate_command_trait_impls_to_inner!` macros move with it. Co-Authored-By: Claude Opus 5 (1M context) --- .../src/completion/completion_suggestions.rs | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 crates/shirabe-symfony-console/src/completion/completion_suggestions.rs (limited to 'crates/shirabe-symfony-console/src/completion/completion_suggestions.rs') diff --git a/crates/shirabe-symfony-console/src/completion/completion_suggestions.rs b/crates/shirabe-symfony-console/src/completion/completion_suggestions.rs new file mode 100644 index 00000000..dd9235ae --- /dev/null +++ b/crates/shirabe-symfony-console/src/completion/completion_suggestions.rs @@ -0,0 +1,76 @@ +//! ref: composer/vendor/symfony/console/Completion/CompletionSuggestions.php + +use crate::completion::suggestion::Suggestion; +use crate::input::input_option::InputOption; + +/// PHP union type `string|Suggestion` used by `suggestValue`/`suggestValues`. +#[derive(Debug)] +pub enum StringOrSuggestion { + String(String), + Suggestion(Suggestion), +} + +/// Stores all completion suggestions for the current input. +#[derive(Debug)] +pub struct CompletionSuggestions { + value_suggestions: Vec, + option_suggestions: Vec>, +} + +impl Default for CompletionSuggestions { + fn default() -> Self { + Self::new() + } +} + +impl CompletionSuggestions { + pub fn new() -> Self { + Self { + value_suggestions: vec![], + option_suggestions: vec![], + } + } + + /// Add a suggested value for an input option or argument. + pub fn suggest_value(&mut self, value: StringOrSuggestion) -> &mut Self { + self.value_suggestions.push(match value { + StringOrSuggestion::Suggestion(value) => value, + StringOrSuggestion::String(value) => Suggestion::new(value), + }); + + self + } + + /// Add multiple suggested values at once for an input option or argument. + pub fn suggest_values(&mut self, values: Vec) -> &mut Self { + for value in values { + self.suggest_value(value); + } + + self + } + + /// Add a suggestion for an input option name. + pub fn suggest_option(&mut self, option: std::rc::Rc) -> &mut Self { + self.option_suggestions.push(option); + + self + } + + /// Add multiple suggestions for input option names at once. + pub fn suggest_options(&mut self, options: Vec>) -> &mut Self { + for option in options { + self.suggest_option(option); + } + + self + } + + pub fn get_option_suggestions(&self) -> &Vec> { + &self.option_suggestions + } + + pub fn get_value_suggestions(&self) -> &Vec { + &self.value_suggestions + } +} -- cgit v1.3.1-4-g156e