diff --git a/clap_complete/tests/snapshots/basic.bash b/clap_complete/tests/snapshots/basic.bash index 39d6014f..f55933fd 100644 --- a/clap_complete/tests/snapshots/basic.bash +++ b/clap_complete/tests/snapshots/basic.bash @@ -53,7 +53,7 @@ _my-app() { return 0 ;; my__app__help__help) - opts="" + opts="-c" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -67,7 +67,7 @@ _my-app() { return 0 ;; my__app__help__test) - opts="" + opts="-c" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/clap_complete/tests/snapshots/basic.elvish b/clap_complete/tests/snapshots/basic.elvish index abff7a00..71494e46 100644 --- a/clap_complete/tests/snapshots/basic.elvish +++ b/clap_complete/tests/snapshots/basic.elvish @@ -37,8 +37,10 @@ set edit:completion:arg-completer[my-app] = {|@words| cand help 'Print this message or the help of the given subcommand(s)' } &'my-app;help;test'= { + cand -c 'c' } &'my-app;help;help'= { + cand -c 'c' } ] $completions[$command] diff --git a/clap_complete/tests/snapshots/basic.fish b/clap_complete/tests/snapshots/basic.fish index 1ee4a9d4..54415fd6 100644 --- a/clap_complete/tests/snapshots/basic.fish +++ b/clap_complete/tests/snapshots/basic.fish @@ -9,3 +9,5 @@ complete -c my-app -n "__fish_seen_subcommand_from test" -s h -l help -d 'Print complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from help" -s c complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from help" -f -a "test" -d 'Subcommand' complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from test; 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 help; and __fish_seen_subcommand_from test" -s c +complete -c my-app -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from help" -s c diff --git a/clap_complete/tests/snapshots/basic.ps1 b/clap_complete/tests/snapshots/basic.ps1 index 9ef67392..242b7e2d 100644 --- a/clap_complete/tests/snapshots/basic.ps1 +++ b/clap_complete/tests/snapshots/basic.ps1 @@ -43,9 +43,11 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock { break } 'my-app;help;test' { + [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'c') break } 'my-app;help;help' { + [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'c') break } }) diff --git a/clap_complete/tests/snapshots/basic.zsh b/clap_complete/tests/snapshots/basic.zsh index 2050e865..ad6c2aec 100644 --- a/clap_complete/tests/snapshots/basic.zsh +++ b/clap_complete/tests/snapshots/basic.zsh @@ -51,10 +51,12 @@ _arguments "${_arguments_options[@]}" / case $line[1] in (test) _arguments "${_arguments_options[@]}" / +'*-c[]' / && ret=0 ;; (help) _arguments "${_arguments_options[@]}" / +'*-c[]' / && ret=0 ;; esac diff --git a/clap_complete_fig/tests/snapshots/basic.fig.js b/clap_complete_fig/tests/snapshots/basic.fig.js index 01439ff1..e488df4b 100644 --- a/clap_complete_fig/tests/snapshots/basic.fig.js +++ b/clap_complete_fig/tests/snapshots/basic.fig.js @@ -26,10 +26,20 @@ const completion: Fig.Spec = { { name: "test", description: "Subcommand", + options: [ + { + name: "-c", + }, + ], }, { name: "help", description: "Print this message or the help of the given subcommand(s)", + options: [ + { + name: "-c", + }, + ], }, ], options: [ diff --git a/clap_complete_fig/tests/snapshots/special_commands.fig.js b/clap_complete_fig/tests/snapshots/special_commands.fig.js index 76cd4c9e..6829eb5f 100644 --- a/clap_complete_fig/tests/snapshots/special_commands.fig.js +++ b/clap_complete_fig/tests/snapshots/special_commands.fig.js @@ -99,6 +99,7 @@ const completion: Fig.Spec = { }, { name: "some-hidden-cmd", + hidden: true, }, { name: "help", diff --git a/src/builder/app_settings.rs b/src/builder/app_settings.rs index 3de45c4d..6b350796 100644 --- a/src/builder/app_settings.rs +++ b/src/builder/app_settings.rs @@ -50,7 +50,6 @@ pub(crate) enum AppSettings { DisableHelpSubcommand, DisableVersionFlag, PropagateVersion, - DisablePropagatedArgs, Hidden, HidePossibleValues, HelpExpected, @@ -104,7 +103,6 @@ bitflags! { const IGNORE_ERRORS = 1 << 44; const MULTICALL = 1 << 45; const EXPAND_HELP_SUBCOMMAND_TREES = 1 << 46; - const DISABLE_PROPAGATED_ARGS = 1 << 47; const NO_OP = 0; } } @@ -144,8 +142,6 @@ impl_settings! { AppSettings, AppFlags, => Flags::DISABLE_VERSION_FLAG, PropagateVersion => Flags::PROPAGATE_VERSION, - DisablePropagatedArgs - => Flags::DISABLE_PROPAGATED_ARGS, HidePossibleValues => Flags::NO_POS_VALUES, HelpExpected diff --git a/src/builder/command.rs b/src/builder/command.rs index f31e0136..18575027 100644 --- a/src/builder/command.rs +++ b/src/builder/command.rs @@ -4067,13 +4067,6 @@ impl Command { debug!("Command::_propagate_global_args:{}", self.name); for sc in &mut self.subcommands { - if sc.is_set(AppSettings::DisablePropagatedArgs) { - debug!( - "Command::_propagate skipping {}, has DisablePropagatedArgs", - sc.get_name() - ); - continue; - } for a in self.args.args().filter(|a| a.is_global_set()) { if sc.find(&a.id).is_some() { debug!( @@ -4165,7 +4158,6 @@ impl Command { help_help_subcmd.version = None; help_help_subcmd.long_version = None; help_help_subcmd = help_help_subcmd - .setting(AppSettings::DisablePropagatedArgs) .setting(AppSettings::DisableHelpFlag) .setting(AppSettings::DisableVersionFlag); @@ -4196,7 +4188,7 @@ impl Command { fn _copy_subtree_for_help(&self) -> Command { let mut cmd = Command::new(self.get_name().to_string()) - .global_setting(AppSettings::DisablePropagatedArgs) + .hide(self.is_hide_set()) .global_setting(AppSettings::DisableHelpFlag) .global_setting(AppSettings::DisableVersionFlag) .subcommands(self.get_subcommands().map(Command::_copy_subtree_for_help));