-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 when TraverseChildren is set #1171
Conversation
1da7a4f
to
1d97c85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. The TraverseChildren
case had been completely missed.
I have a couple of suggested changes.
Also @Luap99, would you mind writing an issue to mention that |
@Luap99 I forgot to ask you to update your commit message, it should have a short title before going into the details. |
b856c0c
to
1def525
Compare
c53431f
to
4d3c1f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Luap99 Nice! Just a couple of minor tweaks if you agree, and the suggestion for the extra test about using Traverse
instead of Find
.
But it works great both for bash and for zsh with go completions.
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 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>
4d3c1f2
to
a3adff6
Compare
@marckhouzam I have updated the code according to your suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @Luap99!! Would you be able to provide some more context / a good way I can test this? I'll merge this once I've tried this out |
@jpmcb I run into this while working on containers/podman#6442. Podman has a local flag called Unfortunately podman is not easy to set up. Therefore I can create a simple example program for you if you want to test it. |
@jpmcb Try this with TraverseChildren true and false on the root cmd and do something like this |
@jpmcb Did you had the time to test this? Is anything else needed? |
Yes, I've tested this out with your example program, thank you very much for the context!! Everything looks good to me. Thanks for the work on this @Luap99 and @marckhouzam |
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 only
if TraverseChildren is true.
Closes #1170
Closes #1172