From 10fd5fe8e3761ac6a894ca090ecd38c1d60e96e9 Mon Sep 17 00:00:00 2001 From: Mixu78 Date: Wed, 31 Jul 2024 13:56:12 +0300 Subject: [PATCH] fix(clap_complete): Add missing option hyphens to the listItemText parameter in PowerShell completions --- clap_complete/src/shells/powershell.rs | 4 +- clap_complete/tests/snapshots/aliases.ps1 | 24 +++---- clap_complete/tests/snapshots/basic.ps1 | 16 ++--- .../tests/snapshots/custom_bin_name.ps1 | 16 ++--- .../tests/snapshots/feature_sample.ps1 | 26 ++++---- clap_complete/tests/snapshots/quoting.ps1 | 44 ++++++------- .../tests/snapshots/special_commands.ps1 | 52 ++++++++-------- .../tests/snapshots/sub_subcommands.ps1 | 62 +++++++++---------- .../tests/snapshots/subcommand_last.ps1 | 12 ++-- .../snapshots/two_multi_valued_arguments.ps1 | 4 +- clap_complete/tests/snapshots/value_hint.ps1 | 44 ++++++------- .../tests/snapshots/value_terminator.ps1 | 4 +- 12 files changed, 154 insertions(+), 154 deletions(-) diff --git a/clap_complete/src/shells/powershell.rs b/clap_complete/src/shells/powershell.rs index 0c84c5fdbfb..efc78aba08a 100644 --- a/clap_complete/src/shells/powershell.rs +++ b/clap_complete/src/shells/powershell.rs @@ -131,7 +131,7 @@ fn generate_aliases(completions: &mut String, preamble: &String, arg: &Arg) { for alias in aliases { let _ = write!( completions, - "{preamble}'-{alias}', '{alias}{}', [CompletionResultType]::ParameterName, '{tooltip}')", + "{preamble}'-{alias}', '-{alias}{}', [CompletionResultType]::ParameterName, '{tooltip}')", // make PowerShell realize there is a difference between `-s` and `-S` if alias.is_uppercase() { " " } else { "" }, ); @@ -142,7 +142,7 @@ fn generate_aliases(completions: &mut String, preamble: &String, arg: &Arg) { for alias in aliases { let _ = write!( completions, - "{preamble}'--{alias}', '{alias}', [CompletionResultType]::ParameterName, '{tooltip}')" + "{preamble}'--{alias}', '--{alias}', [CompletionResultType]::ParameterName, '{tooltip}')" ); } } diff --git a/clap_complete/tests/snapshots/aliases.ps1 b/clap_complete/tests/snapshots/aliases.ps1 index 5095c966091..1d2969f07cc 100644 --- a/clap_complete/tests/snapshots/aliases.ps1 +++ b/clap_complete/tests/snapshots/aliases.ps1 @@ -21,18 +21,18 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { $completions = @(switch ($command) { 'my-app' { - [CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'cmd option') - [CompletionResult]::new('-O', 'O ', [CompletionResultType]::ParameterName, 'cmd option') - [CompletionResult]::new('--option', 'option', [CompletionResultType]::ParameterName, 'cmd option') - [CompletionResult]::new('--opt', 'opt', [CompletionResultType]::ParameterName, 'cmd option') - [CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'cmd flag') - [CompletionResult]::new('-F', 'F ', [CompletionResultType]::ParameterName, 'cmd flag') - [CompletionResult]::new('--flag', 'flag', [CompletionResultType]::ParameterName, 'cmd flag') - [CompletionResult]::new('--flg', 'flg', [CompletionResultType]::ParameterName, 'cmd flag') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('-o', '-o', [CompletionResultType]::ParameterName, 'cmd option') + [CompletionResult]::new('-O', '-O ', [CompletionResultType]::ParameterName, 'cmd option') + [CompletionResult]::new('--option', '--option', [CompletionResultType]::ParameterName, 'cmd option') + [CompletionResult]::new('--opt', '--opt', [CompletionResultType]::ParameterName, 'cmd option') + [CompletionResult]::new('-f', '-f', [CompletionResultType]::ParameterName, 'cmd flag') + [CompletionResult]::new('-F', '-F ', [CompletionResultType]::ParameterName, 'cmd flag') + [CompletionResult]::new('--flag', '--flag', [CompletionResultType]::ParameterName, 'cmd flag') + [CompletionResult]::new('--flg', '--flg', [CompletionResultType]::ParameterName, 'cmd flag') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } }) diff --git a/clap_complete/tests/snapshots/basic.ps1 b/clap_complete/tests/snapshots/basic.ps1 index bb6080951d6..997278e1b18 100644 --- a/clap_complete/tests/snapshots/basic.ps1 +++ b/clap_complete/tests/snapshots/basic.ps1 @@ -21,19 +21,19 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { $completions = @(switch ($command) { 'my-app' { - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'c') - [CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'v') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'c') + [CompletionResult]::new('-v', '-v', [CompletionResultType]::ParameterName, 'v') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') [CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'Subcommand with a second line') [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') break } 'my-app;test' { - [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'd') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'c') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-d', '-d', [CompletionResultType]::ParameterName, 'd') + [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'c') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } 'my-app;help' { diff --git a/clap_complete/tests/snapshots/custom_bin_name.ps1 b/clap_complete/tests/snapshots/custom_bin_name.ps1 index b00876d1a80..408fc3c0224 100644 --- a/clap_complete/tests/snapshots/custom_bin_name.ps1 +++ b/clap_complete/tests/snapshots/custom_bin_name.ps1 @@ -21,19 +21,19 @@ Register-ArgumentCompleter -Native -CommandName 'bin-name' -ScriptBlock { $completions = @(switch ($command) { 'bin-name' { - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'c') - [CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'v') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'c') + [CompletionResult]::new('-v', '-v', [CompletionResultType]::ParameterName, 'v') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') [CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'Subcommand with a second line') [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') break } 'bin-name;test' { - [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'd') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'c') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-d', '-d', [CompletionResultType]::ParameterName, 'd') + [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'c') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } 'bin-name;help' { diff --git a/clap_complete/tests/snapshots/feature_sample.ps1 b/clap_complete/tests/snapshots/feature_sample.ps1 index 4d6853ee5c0..5f15bda2ddd 100644 --- a/clap_complete/tests/snapshots/feature_sample.ps1 +++ b/clap_complete/tests/snapshots/feature_sample.ps1 @@ -21,24 +21,24 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { $completions = @(switch ($command) { 'my-app' { - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('-C', 'C ', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('--conf', 'conf', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('-C', '-C ', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('--conf', '--conf', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') [CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'tests things') [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') break } 'my-app;test' { - [CompletionResult]::new('--case', 'case', [CompletionResultType]::ParameterName, 'the case to test') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--case', '--case', [CompletionResultType]::ParameterName, 'the case to test') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } 'my-app;help' { diff --git a/clap_complete/tests/snapshots/quoting.ps1 b/clap_complete/tests/snapshots/quoting.ps1 index cccbc79c552..b6fd69e914c 100644 --- a/clap_complete/tests/snapshots/quoting.ps1 +++ b/clap_complete/tests/snapshots/quoting.ps1 @@ -21,16 +21,16 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { $completions = @(switch ($command) { 'my-app' { - [CompletionResult]::new('--single-quotes', 'single-quotes', [CompletionResultType]::ParameterName, 'Can be ''always'', ''auto'', or ''never''') - [CompletionResult]::new('--double-quotes', 'double-quotes', [CompletionResultType]::ParameterName, 'Can be "always", "auto", or "never"') - [CompletionResult]::new('--backticks', 'backticks', [CompletionResultType]::ParameterName, 'For more information see `echo test`') - [CompletionResult]::new('--backslash', 'backslash', [CompletionResultType]::ParameterName, 'Avoid ''\n''') - [CompletionResult]::new('--brackets', 'brackets', [CompletionResultType]::ParameterName, 'List packages [filter]') - [CompletionResult]::new('--expansions', 'expansions', [CompletionResultType]::ParameterName, 'Execute the shell command with $SHELL') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--single-quotes', '--single-quotes', [CompletionResultType]::ParameterName, 'Can be ''always'', ''auto'', or ''never''') + [CompletionResult]::new('--double-quotes', '--double-quotes', [CompletionResultType]::ParameterName, 'Can be "always", "auto", or "never"') + [CompletionResult]::new('--backticks', '--backticks', [CompletionResultType]::ParameterName, 'For more information see `echo test`') + [CompletionResult]::new('--backslash', '--backslash', [CompletionResultType]::ParameterName, 'Avoid ''\n''') + [CompletionResult]::new('--brackets', '--brackets', [CompletionResultType]::ParameterName, 'List packages [filter]') + [CompletionResult]::new('--expansions', '--expansions', [CompletionResultType]::ParameterName, 'Execute the shell command with $SHELL') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') [CompletionResult]::new('cmd-single-quotes', 'cmd-single-quotes', [CompletionResultType]::ParameterValue, 'Can be ''always'', ''auto'', or ''never''') [CompletionResult]::new('cmd-double-quotes', 'cmd-double-quotes', [CompletionResultType]::ParameterValue, 'Can be "always", "auto", or "never"') [CompletionResult]::new('cmd-backticks', 'cmd-backticks', [CompletionResultType]::ParameterValue, 'For more information see `echo test`') @@ -41,33 +41,33 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { break } 'my-app;cmd-single-quotes' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } 'my-app;cmd-double-quotes' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } 'my-app;cmd-backticks' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } 'my-app;cmd-backslash' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } 'my-app;cmd-brackets' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } 'my-app;cmd-expansions' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } 'my-app;help' { diff --git a/clap_complete/tests/snapshots/special_commands.ps1 b/clap_complete/tests/snapshots/special_commands.ps1 index 6a16ed3a67a..8d502ad8d4c 100644 --- a/clap_complete/tests/snapshots/special_commands.ps1 +++ b/clap_complete/tests/snapshots/special_commands.ps1 @@ -21,14 +21,14 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { $completions = @(switch ($command) { 'my-app' { - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('-C', 'C ', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('--conf', 'conf', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('-C', '-C ', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('--conf', '--conf', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') [CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'tests things') [CompletionResult]::new('some_cmd', 'some_cmd', [CompletionResultType]::ParameterValue, 'tests other things') [CompletionResult]::new('some-cmd-with-hyphens', 'some-cmd-with-hyphens', [CompletionResultType]::ParameterValue, 'some-cmd-with-hyphens') @@ -37,33 +37,33 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { break } 'my-app;test' { - [CompletionResult]::new('--case', 'case', [CompletionResultType]::ParameterName, 'the case to test') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--case', '--case', [CompletionResultType]::ParameterName, 'the case to test') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } 'my-app;some_cmd' { - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'the other case to test') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'the other case to test') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } 'my-app;some-cmd-with-hyphens' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } 'my-app;some-hidden-cmd' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } 'my-app;help' { diff --git a/clap_complete/tests/snapshots/sub_subcommands.ps1 b/clap_complete/tests/snapshots/sub_subcommands.ps1 index 1cdaf0627c3..2633f17df51 100644 --- a/clap_complete/tests/snapshots/sub_subcommands.ps1 +++ b/clap_complete/tests/snapshots/sub_subcommands.ps1 @@ -21,14 +21,14 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { $completions = @(switch ($command) { 'my-app' { - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('-C', 'C ', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('--conf', 'conf', [CompletionResultType]::ParameterName, 'some config file') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('-C', '-C ', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('--conf', '--conf', [CompletionResultType]::ParameterName, 'some config file') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') [CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'tests things') [CompletionResult]::new('some_cmd', 'some_cmd', [CompletionResultType]::ParameterValue, 'top level subcommand') [CompletionResult]::new('some_cmd_alias', 'some_cmd_alias', [CompletionResultType]::ParameterValue, 'top level subcommand') @@ -36,45 +36,45 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { break } 'my-app;test' { - [CompletionResult]::new('--case', 'case', [CompletionResultType]::ParameterName, 'the case to test') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--case', '--case', [CompletionResultType]::ParameterName, 'the case to test') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } 'my-app;some_cmd' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') [CompletionResult]::new('sub_cmd', 'sub_cmd', [CompletionResultType]::ParameterValue, 'sub-subcommand') [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') break } 'my-app;some_cmd_alias' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') [CompletionResult]::new('sub_cmd', 'sub_cmd', [CompletionResultType]::ParameterValue, 'sub-subcommand') [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') break } 'my-app;some_cmd;sub_cmd' { - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'the other case to test') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'the other case to test') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } 'my-app;some_cmd_alias;sub_cmd' { - [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'the other case to test') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'the other case to test') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } 'my-app;some_cmd;help' { diff --git a/clap_complete/tests/snapshots/subcommand_last.ps1 b/clap_complete/tests/snapshots/subcommand_last.ps1 index 71c4cd8eefd..5bf1d3b6bc1 100644 --- a/clap_complete/tests/snapshots/subcommand_last.ps1 +++ b/clap_complete/tests/snapshots/subcommand_last.ps1 @@ -21,21 +21,21 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { $completions = @(switch ($command) { 'my-app' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') [CompletionResult]::new('foo', 'foo', [CompletionResultType]::ParameterValue, 'foo') [CompletionResult]::new('bar', 'bar', [CompletionResultType]::ParameterValue, 'bar') [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') break } 'my-app;foo' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } 'my-app;bar' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } 'my-app;help' { diff --git a/clap_complete/tests/snapshots/two_multi_valued_arguments.ps1 b/clap_complete/tests/snapshots/two_multi_valued_arguments.ps1 index 30262afe031..dfe67d29212 100644 --- a/clap_complete/tests/snapshots/two_multi_valued_arguments.ps1 +++ b/clap_complete/tests/snapshots/two_multi_valued_arguments.ps1 @@ -21,8 +21,8 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { $completions = @(switch ($command) { 'my-app' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } }) diff --git a/clap_complete/tests/snapshots/value_hint.ps1 b/clap_complete/tests/snapshots/value_hint.ps1 index b228caf3c16..d339b66b5c6 100644 --- a/clap_complete/tests/snapshots/value_hint.ps1 +++ b/clap_complete/tests/snapshots/value_hint.ps1 @@ -21,28 +21,28 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { $completions = @(switch ($command) { 'my-app' { - [CompletionResult]::new('--choice', 'choice', [CompletionResultType]::ParameterName, 'choice') - [CompletionResult]::new('--unknown', 'unknown', [CompletionResultType]::ParameterName, 'unknown') - [CompletionResult]::new('--other', 'other', [CompletionResultType]::ParameterName, 'other') - [CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'p') - [CompletionResult]::new('--path', 'path', [CompletionResultType]::ParameterName, 'path') - [CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'f') - [CompletionResult]::new('--file', 'file', [CompletionResultType]::ParameterName, 'file') - [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'd') - [CompletionResult]::new('--dir', 'dir', [CompletionResultType]::ParameterName, 'dir') - [CompletionResult]::new('-e', 'e', [CompletionResultType]::ParameterName, 'e') - [CompletionResult]::new('--exe', 'exe', [CompletionResultType]::ParameterName, 'exe') - [CompletionResult]::new('--cmd-name', 'cmd-name', [CompletionResultType]::ParameterName, 'cmd-name') - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'c') - [CompletionResult]::new('--cmd', 'cmd', [CompletionResultType]::ParameterName, 'cmd') - [CompletionResult]::new('-u', 'u', [CompletionResultType]::ParameterName, 'u') - [CompletionResult]::new('--user', 'user', [CompletionResultType]::ParameterName, 'user') - [CompletionResult]::new('-H', 'H ', [CompletionResultType]::ParameterName, 'H') - [CompletionResult]::new('--host', 'host', [CompletionResultType]::ParameterName, 'host') - [CompletionResult]::new('--url', 'url', [CompletionResultType]::ParameterName, 'url') - [CompletionResult]::new('--email', 'email', [CompletionResultType]::ParameterName, 'email') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--choice', '--choice', [CompletionResultType]::ParameterName, 'choice') + [CompletionResult]::new('--unknown', '--unknown', [CompletionResultType]::ParameterName, 'unknown') + [CompletionResult]::new('--other', '--other', [CompletionResultType]::ParameterName, 'other') + [CompletionResult]::new('-p', '-p', [CompletionResultType]::ParameterName, 'p') + [CompletionResult]::new('--path', '--path', [CompletionResultType]::ParameterName, 'path') + [CompletionResult]::new('-f', '-f', [CompletionResultType]::ParameterName, 'f') + [CompletionResult]::new('--file', '--file', [CompletionResultType]::ParameterName, 'file') + [CompletionResult]::new('-d', '-d', [CompletionResultType]::ParameterName, 'd') + [CompletionResult]::new('--dir', '--dir', [CompletionResultType]::ParameterName, 'dir') + [CompletionResult]::new('-e', '-e', [CompletionResultType]::ParameterName, 'e') + [CompletionResult]::new('--exe', '--exe', [CompletionResultType]::ParameterName, 'exe') + [CompletionResult]::new('--cmd-name', '--cmd-name', [CompletionResultType]::ParameterName, 'cmd-name') + [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'c') + [CompletionResult]::new('--cmd', '--cmd', [CompletionResultType]::ParameterName, 'cmd') + [CompletionResult]::new('-u', '-u', [CompletionResultType]::ParameterName, 'u') + [CompletionResult]::new('--user', '--user', [CompletionResultType]::ParameterName, 'user') + [CompletionResult]::new('-H', '-H ', [CompletionResultType]::ParameterName, 'H') + [CompletionResult]::new('--host', '--host', [CompletionResultType]::ParameterName, 'host') + [CompletionResult]::new('--url', '--url', [CompletionResultType]::ParameterName, 'url') + [CompletionResult]::new('--email', '--email', [CompletionResultType]::ParameterName, 'email') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } }) diff --git a/clap_complete/tests/snapshots/value_terminator.ps1 b/clap_complete/tests/snapshots/value_terminator.ps1 index 30262afe031..dfe67d29212 100644 --- a/clap_complete/tests/snapshots/value_terminator.ps1 +++ b/clap_complete/tests/snapshots/value_terminator.ps1 @@ -21,8 +21,8 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { $completions = @(switch ($command) { 'my-app' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') break } })