-
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
Enable builtin completion command for root command with only flags #1954
Comments
I believe you need #1559 (which I kind of forgot about). Your workaround of adding an empty hidden subcommand is imaginative, I hadn't considered it. However IIRC it will have some undesirable impacts on how your program processes arguments. This is why we couldn't go with #1450. But maybe it's safe in you specific case? But let me first ask why you need the
That's nice to read. Thank you. |
Oh! I didn't realize that #!/usr/bin/env sh
kubectl config-cleanup __complete "$@" The only thing that isn't quite right is the completion suggestions. The
The
#1559 would be nice to have, but given that the |
I'm working on adding shell completion for my kubectl plugin now that kubernetes/kubernetes#105867 is merged (thank you so much for this btw. I wouldn't even be attempting this otherwise).
My plugin does not have any sub-commands, it only provides flags currently. I was surprised to find that I have to add a hidden sub-command in order to expose the
completion
builtin command.I was able to make this work in the end, but it feels awkward to do it this way, so I thought I should file an issue in case this wasn't the intended behavior:
https://github.com/B23admin/kubectl-config-cleanup/blob/feeb2f1d52c8304a2bf4aa3f4af1dc18bfce4154/cleanup/cleanup.go#L106-L114
I did come across this comment to someone who was having a similar problem, however I'm calling
Execute()
so I think my situation is a little differentThe text was updated successfully, but these errors were encountered: