From 2592062434eeb5fe814dbca953d5fd23458bc135 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 2 Aug 2026 11:04:17 +0900 Subject: feat(symfony-console): implement the shell completion command plumbing The _complete and completion commands were registered but always panicked: get_class_of_command / instantiate_completion_output / tail_debug_log were todo!() and the completion.bash resource was not shipped. - make Command::complete return anyhow::Result so completion errors propagate to CompleteCommand's catch-all (exit code 2) like PHP - add Command::get_class as the port hook for PHP's get_class() debug log; every command supplies its PHP FQCN via the delegation macro - embed Resources/completion.bash at compile time (single-binary port); get_supported_shells becomes a static list - implement tail_debug_log by moving the shared output handle into the 'static process callback - add OutputInterface::as_console_output so unsupported-shell errors go to stderr as in PHP - fix CompletionInput::bind to keep the argument name PHP assigns in the foreach head even when the loop breaks on the first unset argument; application-level completion always hit this and returned no suggestions Co-Authored-By: Claude Fable 5 --- .../symfony/console/command/complete_command.rs | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs') 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 5d8b1a98..dcffb5f8 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 @@ -5,6 +5,7 @@ use crate::symfony::console::completion::completion_input::CompletionInput; use crate::symfony::console::completion::completion_suggestions::{ CompletionSuggestions, StringOrSuggestion, }; +use crate::symfony::console::completion::output::bash_completion_output::BashCompletionOutput; use crate::symfony::console::completion::output::completion_output_interface::CompletionOutputInterface; use crate::symfony::console::input::input_interface::InputInterface; use crate::symfony::console::input::input_option::InputOption; @@ -144,9 +145,7 @@ impl CompleteCommand { fn get_class_of_command(command: &std::rc::Rc>) -> String { // LazyCommand is intentionally not ported. - // TODO: get_class() takes a PhpMixed but the command is a `dyn Command`; reflecting the - // concrete class name of a trait object requires a class-name hook on Command (Phase C). - todo!() + command.borrow().get_class() } fn get_definition_options( @@ -162,8 +161,15 @@ fn get_definition_options( } /// new $completionOutput(); -fn instantiate_completion_output(_class: &PhpMixed) -> Box { - todo!() +fn instantiate_completion_output(class: &PhpMixed) -> Box { + match class.to_string().as_str() { + "Symfony\\Component\\Console\\Completion\\Output\\BashCompletionOutput" => { + Box::new(BashCompletionOutput) + } + // completion_outputs only ever registers the bash output (Composer registers no extra + // ones), so any other FQCN is a programming error. + other => panic!("unknown completion output class: {}", other), + } } impl Command for CompleteCommand { @@ -355,7 +361,7 @@ impl Command for CompleteCommand { command .borrow() - .complete(&completion_input, &mut suggestions); + .complete(&completion_input, &mut suggestions)?; } } } @@ -407,5 +413,8 @@ impl Command for CompleteCommand { } } - crate::delegate_command_trait_impls_to_inner!(inner); + crate::delegate_command_trait_impls_to_inner!( + inner, + "Symfony\\Component\\Console\\Command\\CompleteCommand" + ); } -- cgit v1.3.1