Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub-commands are sometimes completed in bash after a local non-persistent flag #1172

Closed
marckhouzam opened this issue Jul 19, 2020 · 0 comments · Fixed by #1171
Closed

Sub-commands are sometimes completed in bash after a local non-persistent flag #1172

marckhouzam opened this issue Jul 19, 2020 · 0 comments · Fixed by #1171

Comments

@marckhouzam
Copy link
Collaborator

PR #288 added the feature that sub-commands should not be completed if they follow a local non-persistent flag. This is because the sub-command doesn't know that flag and the sub-command would therefore fail.

However, currently, when using the no-= form of a local non-persistent flag with bash, sub-commands are being completed.

Note that when using a boolean flag or the = form for a flag (e.g. integer), sub-commands are not completed after a local non-persistent flag as expected.
Here is an example:

bash-5.0$ ./testprog --local 1 [tab][tab]
child1      completion  help
# Sub-commands are completed when they shouldn't

bash-5.0$ ./testprog --local=1 [tab][tab]
[file completion is done]
# Sub-commands are NOT completed as expected

bash-5.0$ ./testprog --bool [tab][tab]
[file completion is done]
# Sub-commands are NOT completed as expected

My guess is that this bug was introduced along the way as the bash completion script evolved after #288 was implemented.

This only affects bash; zsh and fish completion behave as expected.

Luap99 pushed a commit to Luap99/cobra that referenced this issue Jul 19, 2020
The current bash completion logic does not complete
subcommands when a local flag is set. There is also a bug
where subcommands are sometimes still getting completed. see: spf13#1172

If TraverseChildren is true we should allow subcommands
to be completed even if a local flag is set.

Closes spf13#1172

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Luap99 pushed a commit to Luap99/cobra that referenced this issue Jul 19, 2020
The current bash completion logic does not complete
subcommands when a local flag is set. There is also a bug
where subcommands are sometimes still getting completed. see: spf13#1172

If TraverseChildren is true we should allow subcommands
to be completed even if a local flag is set.

Closes spf13#1172

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Luap99 pushed a commit to Luap99/cobra that referenced this issue Jul 19, 2020
The current bash completion logic does not complete
subcommands when a local flag is set. There is also a bug
where subcommands are sometimes still getting completed. see: spf13#1172

If TraverseChildren is true we should allow subcommands
to be completed even if a local flag is set.

Closes spf13#1172

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Luap99 pushed a commit to Luap99/cobra that referenced this issue Jul 19, 2020
The current bash completion logic does not complete
subcommands when a local flag is set. There is also a bug
where subcommands are sometimes still getting completed. see: spf13#1172

If TraverseChildren is true we should allow subcommands
to be completed even if a local flag is set.

Closes spf13#1172

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Luap99 pushed a commit to Luap99/cobra that referenced this issue Jul 19, 2020
The current bash completion logic does not complete
subcommands when a local flag is set. There is also a bug
where subcommands are sometimes still getting completed. see: spf13#1172

If TraverseChildren is true we should allow subcommands
to be completed even if a local flag is set.

Closes spf13#1172

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Luap99 pushed a commit to Luap99/cobra that referenced this issue Jul 20, 2020
The current bash completion logic does not complete
subcommands when a local flag is set. There is also a bug
where subcommands are sometimes still getting completed. see: spf13#1172

If TraverseChildren is true we should allow subcommands
to be completed even if a local flag is set.

Closes spf13#1172

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
jpmcb pushed a commit that referenced this issue Sep 9, 2020
* Complete subcommands when TraverseChildren is true in custom completion

The current custom completion logic does not complete
subcommands when a local flag is set. This is good unless
TraverseChildren is set to true where local flags
can be set on parent commands.

This commit allows subcommands to be completed
if TraverseChildren is set to true on the root cmd.

Closes #1170

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>

* Complete subcommands when TraverseChildren is true in bash completion

The current bash completion logic does not complete
subcommands when a local flag is set. There is also a bug
where subcommands are sometimes still getting completed. see: #1172

If TraverseChildren is true we should allow subcommands
to be completed even if a local flag is set.

Closes #1172

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant