diff --git a/clap_complete/src/shells/fish.rs b/clap_complete/src/shells/fish.rs index b37cda89614..fd2f3a4f80a 100644 --- a/clap_complete/src/shells/fish.rs +++ b/clap_complete/src/shells/fish.rs @@ -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::>() diff --git a/clap_complete/tests/common.rs b/clap_complete/tests/common.rs index a2ce75daa12..b59cc2c56c7 100644 --- a/clap_complete/tests/common.rs +++ b/clap_complete/tests/common.rs @@ -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); } diff --git a/clap_complete/tests/snapshots/aliases.zsh b/clap_complete/tests/snapshots/aliases.zsh index e3a063a7343..dcb879cbdaf 100644 --- a/clap_complete/tests/snapshots/aliases.zsh +++ b/clap_complete/tests/snapshots/aliases.zsh @@ -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 } diff --git a/clap_complete/tests/snapshots/basic.zsh b/clap_complete/tests/snapshots/basic.zsh index f7407180d8f..6da2ae451e0 100644 --- a/clap_complete/tests/snapshots/basic.zsh +++ b/clap_complete/tests/snapshots/basic.zsh @@ -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 "$@" } diff --git a/clap_complete/tests/snapshots/feature_sample.zsh b/clap_complete/tests/snapshots/feature_sample.zsh index 8019ef3c881..88e8960034e 100644 --- a/clap_complete/tests/snapshots/feature_sample.zsh +++ b/clap_complete/tests/snapshots/feature_sample.zsh @@ -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 "$@" } diff --git a/clap_complete/tests/snapshots/quoting.elvish b/clap_complete/tests/snapshots/quoting.elvish index 44b28cd8b50..95680827cae 100644 --- a/clap_complete/tests/snapshots/quoting.elvish +++ b/clap_complete/tests/snapshots/quoting.elvish @@ -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)' diff --git a/clap_complete/tests/snapshots/quoting.fish b/clap_complete/tests/snapshots/quoting.fish index b13bf5c2ec3..cad4af73241 100644 --- a/clap_complete/tests/snapshots/quoting.fish +++ b/clap_complete/tests/snapshots/quoting.fish @@ -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)' diff --git a/clap_complete/tests/snapshots/quoting.ps1 b/clap_complete/tests/snapshots/quoting.ps1 index 9c75e98dd3a..28662baf03e 100644 --- a/clap_complete/tests/snapshots/quoting.ps1 +++ b/clap_complete/tests/snapshots/quoting.ps1 @@ -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)') diff --git a/clap_complete/tests/snapshots/quoting.zsh b/clap_complete/tests/snapshots/quoting.zsh index 9df120066ca..3ff1a25627a 100644 --- a/clap_complete/tests/snapshots/quoting.zsh +++ b/clap_complete/tests/snapshots/quoting.zsh @@ -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 "$@" } diff --git a/clap_complete/tests/snapshots/special_commands.zsh b/clap_complete/tests/snapshots/special_commands.zsh index 405e503ba2b..37a004711e2 100644 --- a/clap_complete/tests/snapshots/special_commands.zsh +++ b/clap_complete/tests/snapshots/special_commands.zsh @@ -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 "$@" } diff --git a/clap_complete/tests/snapshots/sub_subcommands.bash b/clap_complete/tests/snapshots/sub_subcommands.bash index 31131382a2d..69793078c62 100644 --- a/clap_complete/tests/snapshots/sub_subcommands.bash +++ b/clap_complete/tests/snapshots/sub_subcommands.bash @@ -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 ;; *) diff --git a/clap_complete/tests/snapshots/sub_subcommands.elvish b/clap_complete/tests/snapshots/sub_subcommands.elvish index bf5336ad527..d9c98a91429 100644 --- a/clap_complete/tests/snapshots/sub_subcommands.elvish +++ b/clap_complete/tests/snapshots/sub_subcommands.elvish @@ -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' } diff --git a/clap_complete/tests/snapshots/sub_subcommands.fish b/clap_complete/tests/snapshots/sub_subcommands.fish index 7996d5a028e..7add21c54c6 100644 --- a/clap_complete/tests/snapshots/sub_subcommands.fish +++ b/clap_complete/tests/snapshots/sub_subcommands.fish @@ -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)' diff --git a/clap_complete/tests/snapshots/sub_subcommands.ps1 b/clap_complete/tests/snapshots/sub_subcommands.ps1 index 37bde11d78b..fb5602466e6 100644 --- a/clap_complete/tests/snapshots/sub_subcommands.ps1 +++ b/clap_complete/tests/snapshots/sub_subcommands.ps1 @@ -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 diff --git a/clap_complete/tests/snapshots/sub_subcommands.zsh b/clap_complete/tests/snapshots/sub_subcommands.zsh index 918c76c14e0..be4378d7290 100644 --- a/clap_complete/tests/snapshots/sub_subcommands.zsh +++ b/clap_complete/tests/snapshots/sub_subcommands.zsh @@ -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 "$@" } diff --git a/clap_complete/tests/snapshots/value_hint.zsh b/clap_complete/tests/snapshots/value_hint.zsh index 59fb5cea650..3db2f312ec0 100644 --- a/clap_complete/tests/snapshots/value_hint.zsh +++ b/clap_complete/tests/snapshots/value_hint.zsh @@ -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 }