mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
parent
7353b2be34
commit
7b5bc6640c
7 changed files with 22 additions and 20 deletions
|
@ -124,7 +124,9 @@ 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 { "" },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,16 +22,16 @@ 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('-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('-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('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||
break
|
||||
}
|
||||
|
|
|
@ -22,12 +22,12 @@ 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('-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('-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)')
|
||||
|
@ -37,7 +37,7 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
|
|||
[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('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||
break
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
|
|||
[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('-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"')
|
||||
|
|
|
@ -22,12 +22,12 @@ 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('-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('-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')
|
||||
|
@ -40,7 +40,7 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
|
|||
[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('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||
break
|
||||
}
|
||||
|
@ -48,21 +48,21 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
|
|||
[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('-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('-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('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||
break
|
||||
}
|
||||
|
|
|
@ -22,12 +22,12 @@ 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('-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('-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')
|
||||
|
@ -38,14 +38,14 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
|
|||
[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('-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('-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)')
|
||||
|
@ -55,7 +55,7 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
|
|||
[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('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||
break
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
|
|||
[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('-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')
|
||||
|
|
Loading…
Reference in a new issue