-
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
Request for comments: In-built autocompletion for shell #867
Comments
This issue is being marked as stale due to a long period of inactivity |
@amitsaha I just fell upon this suggestion. You had a great idea! Coincidentally, Cobra has actually started using this technique to provide Fish shell completion (#1048). The same is being applied for zsh completion in #1070. A hidden command was used to achieve this. So you can do things like: |
This suggestion is actually being used by Cobra. I believe this issue can be closed . /cc @jpmcb |
Hi all, since a cobra CLI application already knows what commands/sub-commands and flags it can handle, why not use the cmd API to implement auto-completion itself? That is, say for BASH, we register
$complete -C mycli mycli
- that ismycli
is invoked whenever I type inmycli <TAB>
and then I have logic inmycli
itself to hint to bash what are the possible options for auto-completion. Here's how I implemented it in mymain.go
of a standard cobra CLI app:It seems to be working for me.
Thoughts on this?
The text was updated successfully, but these errors were encountered: