-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Complete subcommands after local flag #1170
Comments
@marckhouzam Is there a special reason for this? Otherwise i would like to change this behavior. |
Yes this is on purpose for local flags. If a command has a local flags it does not get inherited by a subcommand, so it would be wrong to suggest subcommands as they will fail with the error "unknown flag". However for persistent flags, which are inherited by subcommands, we do complete subcommands. Makes sense? |
Yes that makes sence. However in the podman it works like this: I found out that this works because I can open a PR if you agree? |
Aha. I'm not familiar with the |
@Luap99 could you check if the case you mention works with bash completion? |
Yes it does work but regardless of whether |
That is strange. I mimicked the local flag behavior on what was done in the current bash completion... See #288 |
I also noticed there is bug when you have a local boolean flag there is no subcommand completion but after you provide one argument subcommands are suggested. This doesn't happen with a Persistent Flag. |
Nevermind my test setup was wrong ;) |
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 only if TraverseChildren is true. Closes spf13#1170 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
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 only if TraverseChildren is true. Closes spf13#1170 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
I've looked further into this and it seems to be a bug with the current bash completion.
My guess is that this bug was introduced along the way as the bash completion script evolved. |
I've opened #1172 for the discrepancy with bash. |
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 spf13#1170 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
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 spf13#1170 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
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 spf13#1170 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
* 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>
Currently the custom completion does not complete subcommands after a local flag was given.
I think this is wrong since a program can use subcommands even when there were local flags on the root/parent command given.
cobra/custom_completions.go
Lines 283 to 287 in b95db64
The text was updated successfully, but these errors were encountered: