aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-11 16:03:05 +0900
committernsfisis <nsfisis@gmail.com>2026-07-11 16:03:05 +0900
commit1ec2220def43e37e5a65b96dde93c19b493258f4 (patch)
treeecb5188e36a52c31a781117807801e3ac344a541 /crates/shirabe-external-packages
parent5d4f18559c2d07c8f05d6585ffc06866411c5a0f (diff)
downloadphp-shirabe-1ec2220def43e37e5a65b96dde93c19b493258f4.tar.gz
php-shirabe-1ec2220def43e37e5a65b96dde93c19b493258f4.tar.zst
php-shirabe-1ec2220def43e37e5a65b96dde93c19b493258f4.zip
feat(completion): thread Rc<InputOption> through suggest_options
InputDefinition stores options as Rc<InputOption> for sharing, so CompletionSuggestions::suggest_option[s] now accepts Rc<InputOption> instead of owned values, resolving the ownership mismatch left as a todo!() in Application::complete and CompleteCommand.
Diffstat (limited to 'crates/shirabe-external-packages')
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs14
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/completion/completion_suggestions.rs9
2 files changed, 13 insertions, 10 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
index 7df1f802..d64e4a99 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
@@ -151,12 +151,14 @@ fn get_class_of_command(command: &Rc<RefCell<dyn Command>>) -> String {
todo!()
}
-/// $command->getDefinition()->getOptions()
-fn get_definition_options(_command: &Rc<RefCell<dyn Command>>) -> Vec<InputOption> {
- // TODO: InputDefinition::get_options() returns `&IndexMap<String, Rc<InputOption>>` but
- // CompletionSuggestions::suggest_options() takes `Vec<InputOption>`; the option ownership
- // model must be reconciled (Phase C).
- todo!()
+fn get_definition_options(command: &Rc<RefCell<dyn Command>>) -> Vec<Rc<InputOption>> {
+ command
+ .borrow()
+ .get_definition()
+ .get_options()
+ .values()
+ .cloned()
+ .collect()
}
/// new $completionOutput();
diff --git a/crates/shirabe-external-packages/src/symfony/console/completion/completion_suggestions.rs b/crates/shirabe-external-packages/src/symfony/console/completion/completion_suggestions.rs
index 2fb617ab..512056aa 100644
--- a/crates/shirabe-external-packages/src/symfony/console/completion/completion_suggestions.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/completion/completion_suggestions.rs
@@ -2,6 +2,7 @@
use crate::symfony::console::completion::suggestion::Suggestion;
use crate::symfony::console::input::input_option::InputOption;
+use std::rc::Rc;
/// PHP union type `string|Suggestion` used by `suggestValue`/`suggestValues`.
#[derive(Debug)]
@@ -14,7 +15,7 @@ pub enum StringOrSuggestion {
#[derive(Debug)]
pub struct CompletionSuggestions {
value_suggestions: Vec<Suggestion>,
- option_suggestions: Vec<InputOption>,
+ option_suggestions: Vec<Rc<InputOption>>,
}
impl Default for CompletionSuggestions {
@@ -51,14 +52,14 @@ impl CompletionSuggestions {
}
/// Add a suggestion for an input option name.
- pub fn suggest_option(&mut self, option: InputOption) -> &mut Self {
+ pub fn suggest_option(&mut self, option: Rc<InputOption>) -> &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<InputOption>) -> &mut Self {
+ pub fn suggest_options(&mut self, options: Vec<Rc<InputOption>>) -> &mut Self {
for option in options {
self.suggest_option(option);
}
@@ -66,7 +67,7 @@ impl CompletionSuggestions {
self
}
- pub fn get_option_suggestions(&self) -> &Vec<InputOption> {
+ pub fn get_option_suggestions(&self) -> &Vec<Rc<InputOption>> {
&self.option_suggestions
}