diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-02 11:33:44 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-02 11:33:44 +0900 |
| commit | f1dee6362f9b25e78f7e6417e957c0ca34356ecb (patch) | |
| tree | c25c07d81153b4fb12ae840db9c3eb71f5d7fab4 /crates/shirabe/src/command/outdated_command.rs | |
| parent | 876f1bf158cf03944ba56fee351fa97b34fda9e0 (diff) | |
| download | php-shirabe-f1dee6362f9b25e78f7e6417e957c0ca34356ecb.tar.gz php-shirabe-f1dee6362f9b25e78f7e6417e957c0ca34356ecb.tar.zst php-shirabe-f1dee6362f9b25e78f7e6417e957c0ca34356ecb.zip | |
feat(command): wire suggested values into every command definition
Ports the per-command completion metadata that PHP passes as the
suggestedValues constructor argument, resolving all TODO(cli-completion)
markers:
- CompletionTrait providers on 18 argument/option sites (installed/root/
available package names, package types, prefer-install)
- static value lists (--format on show/outdated/search/fund/licenses/
check-platform-reqs, archive's FORMATS, audit --ignore-severity,
update --bump-after-update, repository's action list)
- command-specific closures: ConfigCommand::suggest_setting_keys,
ShowCommand::suggest_package_based_on_mode, RepositoryCommand's
suggest_repo_names/suggest_type_for_add, exec/run-script inline
closures (downcast from the this argument, as the closures are bound
to their concrete command in PHP)
- GlobalCommand::complete, delegating completion to the wrapped
subcommand through CompletionInput::from_string
- a complete() override on every Composer command forwarding to
base_command_complete (BaseCommand inheritance restoration)
Also fixes CompleteCommand to call merge_application_definition(true) as
PHP's default-argument call does; with false the application-level
"command" argument was missing from the bound definition, shifting every
argument-position detection by one.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/outdated_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/outdated_command.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/crates/shirabe/src/command/outdated_command.rs b/crates/shirabe/src/command/outdated_command.rs index 1c03bfdb..202b0762 100644 --- a/crates/shirabe/src/command/outdated_command.rs +++ b/crates/shirabe/src/command/outdated_command.rs @@ -2,9 +2,11 @@ use crate::command::BaseCommand; use crate::command::BaseCommandData; +use crate::command::CompletionTrait; use crate::command::base_command::base_command_initialize; use crate::console::input::InputArgument; use crate::console::input::InputOption; +use crate::console::input::SuggestedValues; use indexmap::IndexMap; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::ArrayInput; @@ -37,11 +39,10 @@ impl OutdatedCommand { impl Command for OutdatedCommand { fn configure(&self) -> anyhow::Result<()> { - // TODO(cli-completion): suggest_installed_package(false, false) for `package` argument and `--ignore` option self.set_name("outdated")?; self.set_description("Shows a list of installed packages that have updates available, including their latest version"); self.set_definition(&[ - InputArgument::new("package", Some(InputArgument::OPTIONAL), "Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.", None).unwrap().into(), + InputArgument::new5("package", Some(InputArgument::OPTIONAL), "Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.", None, self.suggest_installed_package(false, false)).unwrap().into(), InputOption::new("outdated", Some(PhpMixed::String("o".to_string())), Some(InputOption::VALUE_NONE), "Show only packages that are outdated (this is the default, but present here for compat with `show`", None).unwrap().into(), InputOption::new("all", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Show all installed packages with their latest versions", None).unwrap().into(), InputOption::new("locked", None, Some(InputOption::VALUE_NONE), "Shows updates for packages from the lock file, regardless of what is currently in vendor dir", None).unwrap().into(), @@ -51,8 +52,8 @@ impl Command for OutdatedCommand { InputOption::new("minor-only", Some(PhpMixed::String("m".to_string())), Some(InputOption::VALUE_NONE), "Show only packages that have minor SemVer-compatible updates.", None).unwrap().into(), InputOption::new("patch-only", Some(PhpMixed::String("p".to_string())), Some(InputOption::VALUE_NONE), "Show only packages that have patch SemVer-compatible updates.", None).unwrap().into(), InputOption::new("sort-by-age", Some(PhpMixed::String("A".to_string())), Some(InputOption::VALUE_NONE), "Displays the installed version's age, and sorts packages oldest first.", None).unwrap().into(), - InputOption::new("format", Some(PhpMixed::String("f".to_string())), Some(InputOption::VALUE_REQUIRED), "Format of the output: text or json", Some(PhpMixed::String("text".to_string()))).unwrap().into(), - InputOption::new("ignore", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore specified package(s). Can contain wildcards (*). Use it if you don't want to be informed about new versions of some packages.", None).unwrap().into(), + InputOption::new6("format", Some(PhpMixed::String("f".to_string())), Some(InputOption::VALUE_REQUIRED), "Format of the output: text or json", Some(PhpMixed::String("text".to_string())), SuggestedValues::List(vec!["json".to_string(), "text".to_string()])).unwrap().into(), + InputOption::new6("ignore", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore specified package(s). Can contain wildcards (*). Use it if you don't want to be informed about new versions of some packages.", None, self.suggest_installed_package(false, false)).unwrap().into(), InputOption::new("no-dev", None, Some(InputOption::VALUE_NONE), "Disables search in require-dev packages.", None).unwrap().into(), InputOption::new("ignore-platform-req", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore a specific platform requirement (php & ext- packages). Use with the --outdated option", None).unwrap().into(), InputOption::new("ignore-platform-reqs", None, Some(InputOption::VALUE_NONE), "Ignore all platform requirements (php & ext- packages). Use with the --outdated option", None).unwrap().into(), @@ -230,6 +231,14 @@ impl Command for OutdatedCommand { base_command_initialize(self, input, output) } + fn complete( + &self, + input: &shirabe_external_packages::symfony::console::completion::completion_input::CompletionInput, + suggestions: &mut shirabe_external_packages::symfony::console::completion::completion_suggestions::CompletionSuggestions, + ) -> anyhow::Result<()> { + crate::command::base_command::base_command_complete(self, input, suggestions) + } + shirabe_external_packages::delegate_command_trait_impls_to_inner!( base_command_data, "Composer\\Command\\OutdatedCommand" |
