-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Use native zsh completion script generator #3137
Use native zsh completion script generator #3137
Conversation
So far, Skaffold used a wrapper code borrowed from kubectl to use the bash completion script for zsh. Cobra v0.0.5 introduced a native completion script generator for zsh. To support the `source <(...)` use-case, a minor tweak is necessary (also see spf13/cobra#887) Signed-off-by: Cornelius Weig <22861411+corneliusweig@users.noreply.github.com>
Codecov Report
|
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.
LGTM, thanks for this, awesome! :)
The credit goes to @babysnakes |
cmd/skaffold/app/cmd/completion.go
Outdated
out.Write(buf.Bytes()) | ||
io.WriteString(out, zshTail) | ||
_ = rootCmd(cmd).GenZshCompletion(out) | ||
_, _ = io.WriteString(out, zshCompdef) |
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.
Could it be?
rootCmd(cmd).GenZshCompletion(out)
io.WriteString(out, zshCompdef)
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. Only my IDE complains about it, so I explicitly ignored the errors.
Let's ignore kokoro |
Description
So far, Skaffold used a wrapper code borrowed from kubectl to use the bash completion script for zsh. Cobra v0.0.5 introduced a native completion script generator for zsh. To support the
source <(...)
use-case, a minor tweak is necessary (also see spf13/cobra#887).This PR does the required changes to make use of this native zsh completion scrip generator. It offers inline help text when making completion suggestions.
User facing changes
Users of the zsh completion script (generated with
source <( skaffold completion zsh)
) will get improved completion suggestions:Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
Reviewer Notes
Release Notes
Zsh completion now shows inline help text and understands the positional context of flags.