-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Reworked gen-bash-completion
into a more generic completion command
#1967
Conversation
I'm sorry I don't really get why the build is failing and I have a hard time making Gometalinter work locally. |
I pushed a commit to your branch that addresses the linter issues. |
We don't appear to use it ourselves, so I think it's safe to make this change. |
Thanks for the lint fix, I thought I didn't need to handle errors on print functions but it makes sense. |
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 Tirke!
I believe the only place this is used currently is in the docs at
https://github.com/pulumi/docs/blob/f426b531e461c62ec7c55ca884dcc6b133aca9bb/reference/commands.md
If you want to send a PR there for the changes to adapt to this that would be great!
cmd/completion.go
Outdated
// It is hidden by default since it's not commonly used outside of our own build processes. | ||
func newCompletionCmd(root *cobra.Command) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "completion <SHELL>", |
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.
Perhaps we should keep this command name closer to the original - gen-completion
?
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.
fine with me
Why ?
I'm using Zsh (and I'm not the only one 🤣). Pulumi having Zsh completions is great. I will also add completions to the Homebrew Formula when this is merged.
Why not use Cobra
GenZshCompletion
It's currently not good enough. Maybe it will be when spf13/cobra#646 is done.
Implementation
I did the same thing
kubectl
does for Zsh completion. Meaning using the bash completion generated by Cobra and adapting it to a zsh format. The resulting zsh completion file is not perfect (compared to one's where you have a short command description in the output) but it's good enough I think.I also changed the file output to a stdout output. I think it's better than outputting to a file and it will make adding completions in Homebrew straightforward. I don't know if the previous
gen-bash-completion
is used in any Pulumi project so this may break things.