-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add bash and zsh completion support #384
Conversation
18cd7df
to
7a9c03d
Compare
What are the issues with |
pkg/cmd/cli/completion/completion.go
Outdated
@@ -0,0 +1,207 @@ | |||
/* | |||
Copyright 2017 the Heptio Ark contributors. |
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.
2018
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.
fixed
pkg/cmd/cli/completion/completion.go
Outdated
} | ||
|
||
func genZshCompletion(out io.Writer, ark *cobra.Command) { | ||
// The following code has been copied from |
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.
We probably need to move this to third_party
and include the license header from the original file. Let me double check and get back to you later.
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.
sure
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.
ping @ncdc
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.
If you can find a way to put this in third_party
under kubernetes/pkg/kubectl/cmd/completion.go
along with the original license and a line saying that modifications are © Heptio Ark Contributors, that'd probably be best.
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.
fixed
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.
I've actually included both the licences in the new file in third_party, PTAL
Thanks for this! I've verified it works on zsh, but the CLI docs also need updating. You can do so by running |
I don't know that exact issue since I don't use zsh, but it doesn't work for me 🤷♂️ $ source <(ark completion zsh)
_arguments:comparguments:319: can only be called from completion function
_arguments:comparguments:319: can only be called from completion function Most of the projects have the same workaround. |
0cd52d9
to
3c7e162
Compare
@nrb done 🎉 |
3c7e162
to
8815537
Compare
pkg/cmd/cli/completion/completion.go
Outdated
"fmt" | ||
"os" | ||
|
||
kubectlCmd "github.com/heptio/ark/third_party/kubernetes/pkg/kubectl/cmd" |
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.
Please don't camel case import aliases. I'd use kubectlcmd
or kcmd
. Thanks!
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.
changed to kubectlcmd
/* | ||
The original code is from https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/completion.go - | ||
|
||
Copyright 2016 The Kubernetes Authors. |
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.
Add the modifications line below this one:
Modifications copyright 2018 the Heptio Ark contributors.
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.
fixed
limitations under the License. | ||
*/ | ||
|
||
/* |
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.
You can remove this stanza
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.
removed
@containscafeine sorry for the delay - just got back from PTO! |
This commit adds support for auto completion for bash and zsh shells. A new root level command called "completion" has been introduced, and the user can get the auto completion code by running `ark completion bash/zsh`. For bash completion, the built-in GenBashCompletion() from cobra has been used, but for zsh, the built-in GenZshCompletion() is known to cause issues. The workaround has been copied from zsh completion code of kubectl. Signed-off-by: Shubham <shubham@linux.com>
8815537
to
7f3e881
Compare
@ncdc made the changes, PTAL |
Thanks @containscafeine!!! |
source <(velero completion zsh) > ~/.zshrc (Not working for me) I tested it in Linux Mint. |
@marioaparcero Please file a new issue |
This commit adds support for auto completion for bash and zsh
shells. A new root level command called "completion" has been
introduced, and the user can get the auto completion code by
running
ark completion bash/zsh
.For bash completion, the built-in GenBashCompletion() from cobra
has been used, but for zsh, the built-in GenZshCompletion() is
known to cause issues. The workaround has been copied from zsh
completion code of kubectl.
Fixes #381