Merge pull request #4174 from ModProg/4153-value_help_comma

value help comma
This commit is contained in:
Ed Page 2022-09-02 08:48:24 -05:00 committed by GitHub
commit cdb83ae1c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 297 additions and 284 deletions

View file

@ -27,8 +27,13 @@ impl Generator for Fish {
}
// Escape string inside single quotes
fn escape_string(string: &str) -> String {
string.replace('\\', "\\\\").replace('\'', "\\'")
fn escape_string(string: &str, escape_comma: bool) -> String {
let string = string.replace('\\', "\\\\").replace('\'', "\\'");
if escape_comma {
string.replace(',', "\\,")
} else {
string
}
}
fn gen_fish_inner(
@ -88,12 +93,13 @@ fn gen_fish_inner(
if let Some(longs) = option.get_long_and_visible_aliases() {
for long in longs {
template.push_str(format!(" -l {}", escape_string(long)).as_str());
template.push_str(format!(" -l {}", escape_string(long, false)).as_str());
}
}
if let Some(data) = option.get_help() {
template.push_str(format!(" -d '{}'", escape_string(&data.to_string())).as_str());
template
.push_str(format!(" -d '{}'", escape_string(&data.to_string(), false)).as_str());
}
template.push_str(value_completion(option).as_str());
@ -113,12 +119,13 @@ fn gen_fish_inner(
if let Some(longs) = flag.get_long_and_visible_aliases() {
for long in longs {
template.push_str(format!(" -l {}", escape_string(long)).as_str());
template.push_str(format!(" -l {}", escape_string(long, false)).as_str());
}
}
if let Some(data) = flag.get_help() {
template.push_str(format!(" -d '{}'", escape_string(&data.to_string())).as_str());
template
.push_str(format!(" -d '{}'", escape_string(&data.to_string(), false)).as_str());
}
buffer.push_str(template.as_str());
@ -132,7 +139,7 @@ fn gen_fish_inner(
template.push_str(format!(" -a \"{}\"", &subcommand.get_name()).as_str());
if let Some(data) = subcommand.get_about() {
template.push_str(format!(" -d '{}'", escape_string(&data.to_string())).as_str())
template.push_str(format!(" -d '{}'", escape_string(&data.to_string(), false)).as_str())
}
buffer.push_str(template.as_str());
@ -163,8 +170,8 @@ fn value_completion(option: &Arg) -> String {
} else {
Some(format!(
"{}\t{}",
escape_string(value.get_name()).as_str(),
escape_string(&value.get_help().unwrap_or_default().to_string())
escape_string(value.get_name(), true).as_str(),
escape_string(&value.get_help().unwrap_or_default().to_string(), true)
))
})
.collect::<Vec<_>>()

View file

@ -1,3 +1,5 @@
use clap::builder::PossibleValue;
pub fn basic_command(name: &'static str) -> clap::Command {
clap::Command::new(name)
.arg(
@ -154,9 +156,11 @@ pub fn sub_subcommands_command(name: &'static str) -> clap::Command {
clap::Arg::new("config")
.long("config")
.action(clap::ArgAction::Set)
.value_parser([clap::builder::PossibleValue::new(
"Lest quotes aren't escaped.",
)])
.value_parser([
PossibleValue::new("Lest quotes, aren't escaped.")
.help("help,with,comma"),
PossibleValue::new("Second to trigger display of options"),
])
.help("the other case to test"),
),
),
@ -258,5 +262,6 @@ pub fn assert_matches_path(
snapbox::Assert::new()
.action_env("SNAPSHOTS")
.normalize_paths(false)
.matches_path(expected_path, buf);
}

View file

@ -14,20 +14,20 @@ _my-app() {
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" /
'*-o+[cmd option]: : ' /
'*-O+[cmd option]: : ' /
'*--option=[cmd option]: : ' /
'*--opt=[cmd option]: : ' /
'*-f[cmd flag]' /
'*-F[cmd flag]' /
'*--flag[cmd flag]' /
'*--flg[cmd flag]' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
'::positional:' /
_arguments "${_arguments_options[@]}" \
'*-o+[cmd option]: : ' \
'*-O+[cmd option]: : ' \
'*--option=[cmd option]: : ' \
'*--opt=[cmd option]: : ' \
'*-f[cmd flag]' \
'*-F[cmd flag]' \
'*--flag[cmd flag]' \
'*--flg[cmd flag]' \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
'::positional:' \
&& ret=0
}

View file

@ -14,13 +14,13 @@ _my-app() {
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" /
'*-c[]' /
'(-c)*-v[]' /
'*-h[Print help information]' /
'*--help[Print help information]' /
":: :_my-app_commands" /
"*::: :->my-app" /
_arguments "${_arguments_options[@]}" \
'*-c[]' \
'(-c)*-v[]' \
'*-h[Print help information]' \
'*--help[Print help information]' \
":: :_my-app_commands" \
"*::: :->my-app" \
&& ret=0
case $state in
(my-app)
@ -29,17 +29,17 @@ _my-app() {
curcontext="${curcontext%:*:*}:my-app-command-$line[1]:"
case $line[1] in
(test)
_arguments "${_arguments_options[@]}" /
'*-d[]' /
'*-c[]' /
'*-h[Print help information]' /
'*--help[Print help information]' /
_arguments "${_arguments_options[@]}" \
'*-d[]' \
'*-c[]' \
'*-h[Print help information]' \
'*--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
":: :_my-app__help_commands" /
"*::: :->help" /
_arguments "${_arguments_options[@]}" \
":: :_my-app__help_commands" \
"*::: :->help" \
&& ret=0
case $state in
@ -49,11 +49,11 @@ _arguments "${_arguments_options[@]}" /
curcontext="${curcontext%:*:*}:my-app-help-command-$line[1]:"
case $line[1] in
(test)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
esac
@ -68,16 +68,16 @@ esac
(( $+functions[_my-app_commands] )) ||
_my-app_commands() {
local commands; commands=(
'test:Subcommand' /
'help:Print this message or the help of the given subcommand(s)' /
'test:Subcommand' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app commands' commands "$@"
}
(( $+functions[_my-app__help_commands] )) ||
_my-app__help_commands() {
local commands; commands=(
'test:Subcommand' /
'help:Print this message or the help of the given subcommand(s)' /
'test:Subcommand' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app help commands' commands "$@"
}

View file

@ -14,19 +14,19 @@ _my-app() {
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" /
'*-c[some config file]' /
'*-C[some config file]' /
'*--config[some config file]' /
'*--conf[some config file]' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
'::file -- some input file:_files' /
'::choice:(first second)' /
":: :_my-app_commands" /
"*::: :->my-app" /
_arguments "${_arguments_options[@]}" \
'*-c[some config file]' \
'*-C[some config file]' \
'*--config[some config file]' \
'*--conf[some config file]' \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
'::file -- some input file:_files' \
'::choice:(first second)' \
":: :_my-app_commands" \
"*::: :->my-app" \
&& ret=0
case $state in
(my-app)
@ -35,18 +35,18 @@ _my-app() {
curcontext="${curcontext%:*:*}:my-app-command-$line[3]:"
case $line[3] in
(test)
_arguments "${_arguments_options[@]}" /
'*--case=[the case to test]: : ' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
_arguments "${_arguments_options[@]}" \
'*--case=[the case to test]: : ' \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
":: :_my-app__help_commands" /
"*::: :->help" /
_arguments "${_arguments_options[@]}" \
":: :_my-app__help_commands" \
"*::: :->help" \
&& ret=0
case $state in
@ -56,11 +56,11 @@ _arguments "${_arguments_options[@]}" /
curcontext="${curcontext%:*:*}:my-app-help-command-$line[1]:"
case $line[1] in
(test)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
esac
@ -75,16 +75,16 @@ esac
(( $+functions[_my-app_commands] )) ||
_my-app_commands() {
local commands; commands=(
'test:tests things' /
'help:Print this message or the help of the given subcommand(s)' /
'test:tests things' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app commands' commands "$@"
}
(( $+functions[_my-app__help_commands] )) ||
_my-app__help_commands() {
local commands; commands=(
'test:tests things' /
'help:Print this message or the help of the given subcommand(s)' /
'test:tests things' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app help commands' commands "$@"
}

View file

@ -21,7 +21,7 @@ set edit:completion:arg-completer[my-app] = {|@words|
cand --single-quotes 'Can be ''always'', ''auto'', or ''never'''
cand --double-quotes 'Can be "always", "auto", or "never"'
cand --backticks 'For more information see `echo test`'
cand --backslash 'Avoid ''/n'''
cand --backslash 'Avoid ''\n'''
cand --brackets 'List packages [filter]'
cand --expansions 'Execute the shell command with $SHELL'
cand -h 'Print help information'
@ -31,7 +31,7 @@ set edit:completion:arg-completer[my-app] = {|@words|
cand cmd-single-quotes 'Can be ''always'', ''auto'', or ''never'''
cand cmd-double-quotes 'Can be "always", "auto", or "never"'
cand cmd-backticks 'For more information see `echo test`'
cand cmd-backslash 'Avoid ''/n'''
cand cmd-backslash 'Avoid ''\n'''
cand cmd-brackets 'List packages [filter]'
cand cmd-expansions 'Execute the shell command with $SHELL'
cand help 'Print this message or the help of the given subcommand(s)'
@ -64,7 +64,7 @@ set edit:completion:arg-completer[my-app] = {|@words|
cand cmd-single-quotes 'Can be ''always'', ''auto'', or ''never'''
cand cmd-double-quotes 'Can be "always", "auto", or "never"'
cand cmd-backticks 'For more information see `echo test`'
cand cmd-backslash 'Avoid ''/n'''
cand cmd-backslash 'Avoid ''\n'''
cand cmd-brackets 'List packages [filter]'
cand cmd-expansions 'Execute the shell command with $SHELL'
cand help 'Print this message or the help of the given subcommand(s)'

View file

@ -1,15 +1,15 @@
complete -c my-app -n "__fish_use_subcommand" -l single-quotes -d 'Can be /'always/', /'auto/', or /'never/''
complete -c my-app -n "__fish_use_subcommand" -l single-quotes -d 'Can be \'always\', \'auto\', or \'never\''
complete -c my-app -n "__fish_use_subcommand" -l double-quotes -d 'Can be "always", "auto", or "never"'
complete -c my-app -n "__fish_use_subcommand" -l backticks -d 'For more information see `echo test`'
complete -c my-app -n "__fish_use_subcommand" -l backslash -d 'Avoid /'//n/''
complete -c my-app -n "__fish_use_subcommand" -l backslash -d 'Avoid \'\\n\''
complete -c my-app -n "__fish_use_subcommand" -l brackets -d 'List packages [filter]'
complete -c my-app -n "__fish_use_subcommand" -l expansions -d 'Execute the shell command with $SHELL'
complete -c my-app -n "__fish_use_subcommand" -s h -l help -d 'Print help information'
complete -c my-app -n "__fish_use_subcommand" -s V -l version -d 'Print version information'
complete -c my-app -n "__fish_use_subcommand" -f -a "cmd-single-quotes" -d 'Can be /'always/', /'auto/', or /'never/''
complete -c my-app -n "__fish_use_subcommand" -f -a "cmd-single-quotes" -d 'Can be \'always\', \'auto\', or \'never\''
complete -c my-app -n "__fish_use_subcommand" -f -a "cmd-double-quotes" -d 'Can be "always", "auto", or "never"'
complete -c my-app -n "__fish_use_subcommand" -f -a "cmd-backticks" -d 'For more information see `echo test`'
complete -c my-app -n "__fish_use_subcommand" -f -a "cmd-backslash" -d 'Avoid /'//n/''
complete -c my-app -n "__fish_use_subcommand" -f -a "cmd-backslash" -d 'Avoid \'\\n\''
complete -c my-app -n "__fish_use_subcommand" -f -a "cmd-brackets" -d 'List packages [filter]'
complete -c my-app -n "__fish_use_subcommand" -f -a "cmd-expansions" -d 'Execute the shell command with $SHELL'
complete -c my-app -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
@ -19,10 +19,10 @@ complete -c my-app -n "__fish_seen_subcommand_from cmd-backticks" -s h -l help -
complete -c my-app -n "__fish_seen_subcommand_from cmd-backslash" -s h -l help -d 'Print help information'
complete -c my-app -n "__fish_seen_subcommand_from cmd-brackets" -s h -l help -d 'Print help information'
complete -c my-app -n "__fish_seen_subcommand_from cmd-expansions" -s h -l help -d 'Print help information'
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from cmd-single-quotes; and not __fish_seen_subcommand_from cmd-double-quotes; and not __fish_seen_subcommand_from cmd-backticks; and not __fish_seen_subcommand_from cmd-backslash; and not __fish_seen_subcommand_from cmd-brackets; and not __fish_seen_subcommand_from cmd-expansions; and not __fish_seen_subcommand_from help" -f -a "cmd-single-quotes" -d 'Can be /'always/', /'auto/', or /'never/''
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from cmd-single-quotes; and not __fish_seen_subcommand_from cmd-double-quotes; and not __fish_seen_subcommand_from cmd-backticks; and not __fish_seen_subcommand_from cmd-backslash; and not __fish_seen_subcommand_from cmd-brackets; and not __fish_seen_subcommand_from cmd-expansions; and not __fish_seen_subcommand_from help" -f -a "cmd-single-quotes" -d 'Can be \'always\', \'auto\', or \'never\''
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from cmd-single-quotes; and not __fish_seen_subcommand_from cmd-double-quotes; and not __fish_seen_subcommand_from cmd-backticks; and not __fish_seen_subcommand_from cmd-backslash; and not __fish_seen_subcommand_from cmd-brackets; and not __fish_seen_subcommand_from cmd-expansions; and not __fish_seen_subcommand_from help" -f -a "cmd-double-quotes" -d 'Can be "always", "auto", or "never"'
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from cmd-single-quotes; and not __fish_seen_subcommand_from cmd-double-quotes; and not __fish_seen_subcommand_from cmd-backticks; and not __fish_seen_subcommand_from cmd-backslash; and not __fish_seen_subcommand_from cmd-brackets; and not __fish_seen_subcommand_from cmd-expansions; and not __fish_seen_subcommand_from help" -f -a "cmd-backticks" -d 'For more information see `echo test`'
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from cmd-single-quotes; and not __fish_seen_subcommand_from cmd-double-quotes; and not __fish_seen_subcommand_from cmd-backticks; and not __fish_seen_subcommand_from cmd-backslash; and not __fish_seen_subcommand_from cmd-brackets; and not __fish_seen_subcommand_from cmd-expansions; and not __fish_seen_subcommand_from help" -f -a "cmd-backslash" -d 'Avoid /'//n/''
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from cmd-single-quotes; and not __fish_seen_subcommand_from cmd-double-quotes; and not __fish_seen_subcommand_from cmd-backticks; and not __fish_seen_subcommand_from cmd-backslash; and not __fish_seen_subcommand_from cmd-brackets; and not __fish_seen_subcommand_from cmd-expansions; and not __fish_seen_subcommand_from help" -f -a "cmd-backslash" -d 'Avoid \'\\n\''
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from cmd-single-quotes; and not __fish_seen_subcommand_from cmd-double-quotes; and not __fish_seen_subcommand_from cmd-backticks; and not __fish_seen_subcommand_from cmd-backslash; and not __fish_seen_subcommand_from cmd-brackets; and not __fish_seen_subcommand_from cmd-expansions; and not __fish_seen_subcommand_from help" -f -a "cmd-brackets" -d 'List packages [filter]'
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from cmd-single-quotes; and not __fish_seen_subcommand_from cmd-double-quotes; and not __fish_seen_subcommand_from cmd-backticks; and not __fish_seen_subcommand_from cmd-backslash; and not __fish_seen_subcommand_from cmd-brackets; and not __fish_seen_subcommand_from cmd-expansions; and not __fish_seen_subcommand_from help" -f -a "cmd-expansions" -d 'Execute the shell command with $SHELL'
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from cmd-single-quotes; and not __fish_seen_subcommand_from cmd-double-quotes; and not __fish_seen_subcommand_from cmd-backticks; and not __fish_seen_subcommand_from cmd-backslash; and not __fish_seen_subcommand_from cmd-brackets; and not __fish_seen_subcommand_from cmd-expansions; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'

View file

@ -24,7 +24,7 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
[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('--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 information')
@ -34,7 +34,7 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
[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`')
[CompletionResult]::new('cmd-backslash', 'cmd-backslash', [CompletionResultType]::ParameterValue, 'Avoid ''/n''')
[CompletionResult]::new('cmd-backslash', 'cmd-backslash', [CompletionResultType]::ParameterValue, 'Avoid ''\n''')
[CompletionResult]::new('cmd-brackets', 'cmd-brackets', [CompletionResultType]::ParameterValue, 'List packages [filter]')
[CompletionResult]::new('cmd-expansions', 'cmd-expansions', [CompletionResultType]::ParameterValue, 'Execute the shell command with $SHELL')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
@ -74,7 +74,7 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
[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`')
[CompletionResult]::new('cmd-backslash', 'cmd-backslash', [CompletionResultType]::ParameterValue, 'Avoid ''/n''')
[CompletionResult]::new('cmd-backslash', 'cmd-backslash', [CompletionResultType]::ParameterValue, 'Avoid ''\n''')
[CompletionResult]::new('cmd-brackets', 'cmd-brackets', [CompletionResultType]::ParameterValue, 'List packages [filter]')
[CompletionResult]::new('cmd-expansions', 'cmd-expansions', [CompletionResultType]::ParameterValue, 'Execute the shell command with $SHELL')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')

View file

@ -14,19 +14,19 @@ _my-app() {
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" /
'*--single-quotes[Can be '/''always'/'', '/''auto'/'', or '/''never'/'']' /
'*--double-quotes[Can be "always", "auto", or "never"]' /
'*--backticks[For more information see `echo test`]' /
'*--backslash[Avoid '/''//n'/'']' /
'*--brackets[List packages /[filter/]]' /
'*--expansions[Execute the shell command with $SHELL]' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
":: :_my-app_commands" /
"*::: :->my-app" /
_arguments "${_arguments_options[@]}" \
'*--single-quotes[Can be '\''always'\'', '\''auto'\'', or '\''never'\'']' \
'*--double-quotes[Can be "always", "auto", or "never"]' \
'*--backticks[For more information see `echo test`]' \
'*--backslash[Avoid '\''\\n'\'']' \
'*--brackets[List packages \[filter\]]' \
'*--expansions[Execute the shell command with $SHELL]' \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
":: :_my-app_commands" \
"*::: :->my-app" \
&& ret=0
case $state in
(my-app)
@ -35,45 +35,45 @@ _my-app() {
curcontext="${curcontext%:*:*}:my-app-command-$line[1]:"
case $line[1] in
(cmd-single-quotes)
_arguments "${_arguments_options[@]}" /
'*-h[Print help information]' /
'*--help[Print help information]' /
_arguments "${_arguments_options[@]}" \
'*-h[Print help information]' \
'*--help[Print help information]' \
&& ret=0
;;
(cmd-double-quotes)
_arguments "${_arguments_options[@]}" /
'*-h[Print help information]' /
'*--help[Print help information]' /
_arguments "${_arguments_options[@]}" \
'*-h[Print help information]' \
'*--help[Print help information]' \
&& ret=0
;;
(cmd-backticks)
_arguments "${_arguments_options[@]}" /
'*-h[Print help information]' /
'*--help[Print help information]' /
_arguments "${_arguments_options[@]}" \
'*-h[Print help information]' \
'*--help[Print help information]' \
&& ret=0
;;
(cmd-backslash)
_arguments "${_arguments_options[@]}" /
'*-h[Print help information]' /
'*--help[Print help information]' /
_arguments "${_arguments_options[@]}" \
'*-h[Print help information]' \
'*--help[Print help information]' \
&& ret=0
;;
(cmd-brackets)
_arguments "${_arguments_options[@]}" /
'*-h[Print help information]' /
'*--help[Print help information]' /
_arguments "${_arguments_options[@]}" \
'*-h[Print help information]' \
'*--help[Print help information]' \
&& ret=0
;;
(cmd-expansions)
_arguments "${_arguments_options[@]}" /
'*-h[Print help information]' /
'*--help[Print help information]' /
_arguments "${_arguments_options[@]}" \
'*-h[Print help information]' \
'*--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
":: :_my-app__help_commands" /
"*::: :->help" /
_arguments "${_arguments_options[@]}" \
":: :_my-app__help_commands" \
"*::: :->help" \
&& ret=0
case $state in
@ -83,31 +83,31 @@ _arguments "${_arguments_options[@]}" /
curcontext="${curcontext%:*:*}:my-app-help-command-$line[1]:"
case $line[1] in
(cmd-single-quotes)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(cmd-double-quotes)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(cmd-backticks)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(cmd-backslash)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(cmd-brackets)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(cmd-expansions)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
esac
@ -122,13 +122,13 @@ esac
(( $+functions[_my-app_commands] )) ||
_my-app_commands() {
local commands; commands=(
'cmd-single-quotes:Can be '/''always'/'', '/''auto'/'', or '/''never'/''' /
'cmd-double-quotes:Can be "always", "auto", or "never"' /
'cmd-backticks:For more information see `echo test`' /
'cmd-backslash:Avoid '/''//n'/''' /
'cmd-brackets:List packages /[filter/]' /
'cmd-expansions:Execute the shell command with $SHELL' /
'help:Print this message or the help of the given subcommand(s)' /
'cmd-single-quotes:Can be '\''always'\'', '\''auto'\'', or '\''never'\''' \
'cmd-double-quotes:Can be "always", "auto", or "never"' \
'cmd-backticks:For more information see `echo test`' \
'cmd-backslash:Avoid '\''\\n'\''' \
'cmd-brackets:List packages \[filter\]' \
'cmd-expansions:Execute the shell command with $SHELL' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app commands' commands "$@"
}
@ -195,13 +195,13 @@ _my-app__help__cmd-single-quotes_commands() {
(( $+functions[_my-app__help_commands] )) ||
_my-app__help_commands() {
local commands; commands=(
'cmd-single-quotes:Can be '/''always'/'', '/''auto'/'', or '/''never'/''' /
'cmd-double-quotes:Can be "always", "auto", or "never"' /
'cmd-backticks:For more information see `echo test`' /
'cmd-backslash:Avoid '/''//n'/''' /
'cmd-brackets:List packages /[filter/]' /
'cmd-expansions:Execute the shell command with $SHELL' /
'help:Print this message or the help of the given subcommand(s)' /
'cmd-single-quotes:Can be '\''always'\'', '\''auto'\'', or '\''never'\''' \
'cmd-double-quotes:Can be "always", "auto", or "never"' \
'cmd-backticks:For more information see `echo test`' \
'cmd-backslash:Avoid '\''\\n'\''' \
'cmd-brackets:List packages \[filter\]' \
'cmd-expansions:Execute the shell command with $SHELL' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app help commands' commands "$@"
}

View file

@ -14,19 +14,19 @@ _my-app() {
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" /
'*-c[some config file]' /
'*-C[some config file]' /
'*--config[some config file]' /
'*--conf[some config file]' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
'::file -- some input file:_files' /
'::choice:(first second)' /
":: :_my-app_commands" /
"*::: :->my-app" /
_arguments "${_arguments_options[@]}" \
'*-c[some config file]' \
'*-C[some config file]' \
'*--config[some config file]' \
'*--conf[some config file]' \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
'::file -- some input file:_files' \
'::choice:(first second)' \
":: :_my-app_commands" \
"*::: :->my-app" \
&& ret=0
case $state in
(my-app)
@ -35,44 +35,44 @@ _my-app() {
curcontext="${curcontext%:*:*}:my-app-command-$line[3]:"
case $line[3] in
(test)
_arguments "${_arguments_options[@]}" /
'*--case=[the case to test]: : ' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
_arguments "${_arguments_options[@]}" \
'*--case=[the case to test]: : ' \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
&& ret=0
;;
(some_cmd)
_arguments "${_arguments_options[@]}" /
'*--config=[the other case to test]: : ' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
'*::path:' /
_arguments "${_arguments_options[@]}" \
'*--config=[the other case to test]: : ' \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
'*::path:' \
&& ret=0
;;
(some-cmd-with-hyphens)
_arguments "${_arguments_options[@]}" /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
_arguments "${_arguments_options[@]}" \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
&& ret=0
;;
(some-hidden-cmd)
_arguments "${_arguments_options[@]}" /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
_arguments "${_arguments_options[@]}" \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
":: :_my-app__help_commands" /
"*::: :->help" /
_arguments "${_arguments_options[@]}" \
":: :_my-app__help_commands" \
"*::: :->help" \
&& ret=0
case $state in
@ -82,23 +82,23 @@ _arguments "${_arguments_options[@]}" /
curcontext="${curcontext%:*:*}:my-app-help-command-$line[1]:"
case $line[1] in
(test)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(some_cmd)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(some-cmd-with-hyphens)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(some-hidden-cmd)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
esac
@ -113,22 +113,22 @@ esac
(( $+functions[_my-app_commands] )) ||
_my-app_commands() {
local commands; commands=(
'test:tests things' /
'some_cmd:tests other things' /
'some-cmd-with-hyphens:' /
'some-hidden-cmd:' /
'help:Print this message or the help of the given subcommand(s)' /
'test:tests things' \
'some_cmd:tests other things' \
'some-cmd-with-hyphens:' \
'some-hidden-cmd:' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app commands' commands "$@"
}
(( $+functions[_my-app__help_commands] )) ||
_my-app__help_commands() {
local commands; commands=(
'test:tests things' /
'some_cmd:tests other things' /
'some-cmd-with-hyphens:' /
'some-hidden-cmd:' /
'help:Print this message or the help of the given subcommand(s)' /
'test:tests things' \
'some_cmd:tests other things' \
'some-cmd-with-hyphens:' \
'some-hidden-cmd:' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app help commands' commands "$@"
}

View file

@ -178,7 +178,7 @@ _my-app() {
fi
case "${prev}" in
--config)
COMPREPLY=($(compgen -W "Lest quotes aren't escaped." -- "${cur}"))
COMPREPLY=($(compgen -W "Lest quotes, aren't escaped. Second to trigger display of options" -- "${cur}"))
return 0
;;
*)

View file

@ -47,8 +47,8 @@ set edit:completion:arg-completer[my-app] = {|@words|
}
&'my-app;some_cmd;sub_cmd'= {
cand --config 'the other case to test'
cand -h 'Print help information'
cand --help 'Print help information'
cand -h 'Print help information (use `--help` for more detail)'
cand --help 'Print help information (use `--help` for more detail)'
cand -V 'Print version information'
cand --version 'Print version information'
}

View file

@ -11,8 +11,8 @@ complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and not __fish_seen
complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and not __fish_seen_subcommand_from sub_cmd; and not __fish_seen_subcommand_from help" -s V -l version -d 'Print version information'
complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and not __fish_seen_subcommand_from sub_cmd; and not __fish_seen_subcommand_from help" -f -a "sub_cmd" -d 'sub-subcommand'
complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and not __fish_seen_subcommand_from sub_cmd; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and __fish_seen_subcommand_from sub_cmd" -l config -d 'the other case to test' -r -f -a "{Lest quotes aren/'t escaped. }"
complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and __fish_seen_subcommand_from sub_cmd" -s h -l help -d 'Print help information'
complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and __fish_seen_subcommand_from sub_cmd" -l config -d 'the other case to test' -r -f -a "{Lest quotes\, aren\'t escaped. help\,with\,comma,Second to trigger display of options }"
complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and __fish_seen_subcommand_from sub_cmd" -s h -l help -d 'Print help information (use `--help` for more detail)'
complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and __fish_seen_subcommand_from sub_cmd" -s V -l version -d 'Print version information'
complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from sub_cmd; and not __fish_seen_subcommand_from help" -f -a "sub_cmd" -d 'sub-subcommand'
complete -c my-app -n "__fish_seen_subcommand_from some_cmd; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from sub_cmd; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'

View file

@ -53,8 +53,8 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
}
'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 information')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information (use `--help` for more detail)')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information (use `--help` for more detail)')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
break

View file

@ -14,19 +14,19 @@ _my-app() {
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" /
'*-c[some config file]' /
'*-C[some config file]' /
'*--config[some config file]' /
'*--conf[some config file]' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
'::file -- some input file:_files' /
'::choice:(first second)' /
":: :_my-app_commands" /
"*::: :->my-app" /
_arguments "${_arguments_options[@]}" \
'*-c[some config file]' \
'*-C[some config file]' \
'*--config[some config file]' \
'*--conf[some config file]' \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
'::file -- some input file:_files' \
'::choice:(first second)' \
":: :_my-app_commands" \
"*::: :->my-app" \
&& ret=0
case $state in
(my-app)
@ -35,22 +35,22 @@ _my-app() {
curcontext="${curcontext%:*:*}:my-app-command-$line[3]:"
case $line[3] in
(test)
_arguments "${_arguments_options[@]}" /
'*--case=[the case to test]: : ' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
_arguments "${_arguments_options[@]}" \
'*--case=[the case to test]: : ' \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
&& ret=0
;;
(some_cmd)
_arguments "${_arguments_options[@]}" /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
":: :_my-app__some_cmd_commands" /
"*::: :->some_cmd" /
_arguments "${_arguments_options[@]}" \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
":: :_my-app__some_cmd_commands" \
"*::: :->some_cmd" \
&& ret=0
case $state in
@ -60,18 +60,19 @@ _arguments "${_arguments_options[@]}" /
curcontext="${curcontext%:*:*}:my-app-some_cmd-command-$line[1]:"
case $line[1] in
(sub_cmd)
_arguments "${_arguments_options[@]}" /
'*--config=[the other case to test]: :(Lest quotes aren't escaped.)' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*-V[Print version information]' /
'*--version[Print version information]' /
_arguments "${_arguments_options[@]}" \
'*--config=[the other case to test]: :((Lest\ quotes,\ aren'\''t\ escaped.\:"help,with,comma"
Second\ to\ trigger\ display\ of\ options\:""))' \
'*-h[Print help information (use `--help` for more detail)]' \
'*--help[Print help information (use `--help` for more detail)]' \
'*-V[Print version information]' \
'*--version[Print version information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
":: :_my-app__some_cmd__help_commands" /
"*::: :->help" /
_arguments "${_arguments_options[@]}" \
":: :_my-app__some_cmd__help_commands" \
"*::: :->help" \
&& ret=0
case $state in
@ -81,11 +82,11 @@ _arguments "${_arguments_options[@]}" /
curcontext="${curcontext%:*:*}:my-app-some_cmd-help-command-$line[1]:"
case $line[1] in
(sub_cmd)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
esac
@ -97,9 +98,9 @@ esac
esac
;;
(help)
_arguments "${_arguments_options[@]}" /
":: :_my-app__help_commands" /
"*::: :->help" /
_arguments "${_arguments_options[@]}" \
":: :_my-app__help_commands" \
"*::: :->help" \
&& ret=0
case $state in
@ -109,13 +110,13 @@ _arguments "${_arguments_options[@]}" /
curcontext="${curcontext%:*:*}:my-app-help-command-$line[1]:"
case $line[1] in
(test)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(some_cmd)
_arguments "${_arguments_options[@]}" /
":: :_my-app__help__some_cmd_commands" /
"*::: :->some_cmd" /
_arguments "${_arguments_options[@]}" \
":: :_my-app__help__some_cmd_commands" \
"*::: :->some_cmd" \
&& ret=0
case $state in
@ -125,7 +126,7 @@ _arguments "${_arguments_options[@]}" /
curcontext="${curcontext%:*:*}:my-app-help-some_cmd-command-$line[1]:"
case $line[1] in
(sub_cmd)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
esac
@ -133,7 +134,7 @@ _arguments "${_arguments_options[@]}" /
esac
;;
(help)
_arguments "${_arguments_options[@]}" /
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
esac
@ -148,18 +149,18 @@ esac
(( $+functions[_my-app_commands] )) ||
_my-app_commands() {
local commands; commands=(
'test:tests things' /
'some_cmd:top level subcommand' /
'help:Print this message or the help of the given subcommand(s)' /
'test:tests things' \
'some_cmd:top level subcommand' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app commands' commands "$@"
}
(( $+functions[_my-app__help_commands] )) ||
_my-app__help_commands() {
local commands; commands=(
'test:tests things' /
'some_cmd:top level subcommand' /
'help:Print this message or the help of the given subcommand(s)' /
'test:tests things' \
'some_cmd:top level subcommand' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app help commands' commands "$@"
}
@ -171,8 +172,8 @@ _my-app__help__help_commands() {
(( $+functions[_my-app__some_cmd__help_commands] )) ||
_my-app__some_cmd__help_commands() {
local commands; commands=(
'sub_cmd:sub-subcommand' /
'help:Print this message or the help of the given subcommand(s)' /
'sub_cmd:sub-subcommand' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app some_cmd help commands' commands "$@"
}
@ -184,15 +185,15 @@ _my-app__some_cmd__help__help_commands() {
(( $+functions[_my-app__help__some_cmd_commands] )) ||
_my-app__help__some_cmd_commands() {
local commands; commands=(
'sub_cmd:sub-subcommand' /
'sub_cmd:sub-subcommand' \
)
_describe -t commands 'my-app help some_cmd commands' commands "$@"
}
(( $+functions[_my-app__some_cmd_commands] )) ||
_my-app__some_cmd_commands() {
local commands; commands=(
'sub_cmd:sub-subcommand' /
'help:Print this message or the help of the given subcommand(s)' /
'sub_cmd:sub-subcommand' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app some_cmd commands' commands "$@"
}

View file

@ -14,30 +14,30 @@ _my-app() {
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" /
'*--choice=[]: :(bash fish zsh)' /
'*--unknown=[]: : ' /
'*--other=[]: :( )' /
'*-p+[]: :_files' /
'*--path=[]: :_files' /
'*-f+[]: :_files' /
'*--file=[]: :_files' /
'*-d+[]: :_files -/' /
'*--dir=[]: :_files -/' /
'*-e+[]: :_absolute_command_paths' /
'*--exe=[]: :_absolute_command_paths' /
'*--cmd-name=[]: :_command_names -e' /
'*-c+[]: :_cmdstring' /
'*--cmd=[]: :_cmdstring' /
'*-u+[]: :_users' /
'*--user=[]: :_users' /
'*-H+[]: :_hosts' /
'*--host=[]: :_hosts' /
'*--url=[]: :_urls' /
'*--email=[]: :_email_addresses' /
'*-h[Print help information]' /
'*--help[Print help information]' /
'*::command_with_args:_cmdambivalent' /
_arguments "${_arguments_options[@]}" \
'*--choice=[]: :(bash fish zsh)' \
'*--unknown=[]: : ' \
'*--other=[]: :( )' \
'*-p+[]: :_files' \
'*--path=[]: :_files' \
'*-f+[]: :_files' \
'*--file=[]: :_files' \
'*-d+[]: :_files -/' \
'*--dir=[]: :_files -/' \
'*-e+[]: :_absolute_command_paths' \
'*--exe=[]: :_absolute_command_paths' \
'*--cmd-name=[]: :_command_names -e' \
'*-c+[]: :_cmdstring' \
'*--cmd=[]: :_cmdstring' \
'*-u+[]: :_users' \
'*--user=[]: :_users' \
'*-H+[]: :_hosts' \
'*--host=[]: :_hosts' \
'*--url=[]: :_urls' \
'*--email=[]: :_email_addresses' \
'*-h[Print help information]' \
'*--help[Print help information]' \
'*::command_with_args:_cmdambivalent' \
&& ret=0
}