Repository navigation
Conversation
|
Sorry for the noise on this PR. I first tried to change the name of the binary directly when the command is created, but it leads to tests not passing because the name is also used for usage, and tests hardcode "helm" binary name. So i went for a method were i override "just-in-time" the name of the command, in order to generate completion with cobra only and get rid of any "completion" code specific to a shell in helm. Then i added the support for the shells cobra already supports. Feel free to comment |
There was a problem hiding this comment.
I'm really excited about this contribution! It is great to see others getting involved with Helm completion code.
Note that for the Fish completion code to also work with Cobra 1.0, we need PR #7906 to get merged.
| } | ||
| __helm_compopt() { | ||
| true # don't do anything. Not supported by bashcompinit in zsh | ||
| return cmd.GenZshCompletion(out) |
There was a problem hiding this comment.
Cobra 1.0's support for Zsh is a lesser solution than what helm currently provides.
The biggest issue is that it does not support custom completions, so
helm status <TAB> would no longer work, for example.
We first need spf13/cobra#1070 to be merged and released before we can start using Cobra's Zsh completion.
| // both helm2 and helm3), we overwrite the new binary name to the command | ||
| // in order to generate proper completion | ||
| rootCmd := cmd.Root() | ||
| rootCmd.Use = filepath.Base(os.Args[0]) |
There was a problem hiding this comment.
I'm a little concerned about unknown side-effects of doing this.
But it may be ok. I'm just leaving a note to keep thinking about it.
There was a problem hiding this comment.
We might want to create a deep copy of the command?
I haven't investigated much as if the command was still used afterwards.
There was a problem hiding this comment.
Simpler than a deep-copy could be to
- set Use field
- generate completion script
- reset Use field to old value.
But all this feels hacky to me.
There was a problem hiding this comment.
Seems hacky to me too, but i think that's a job for cobra, it definitly should be configurable.
Meanwhile we might want something like that.
I changed the way it was done in order to save/restore the Use field in fe31b1d
|
I just remembered that as it stands, custom completions ( I have a patch ready for that but it first needs #7906 to get merged. |
#7906 was merged 🎉 and I have posted the follow-up PR #8131 which is required to allow Fish completions to have custom completions. |
|
Sorry for the late response, there should be only fish completion related changes. |
| } | ||
|
|
||
| func runCompletionFish(out io.Writer, cmd *cobra.Command) error { | ||
| return cmd.GenFishCompletion(out, !completionNoDesc) |
There was a problem hiding this comment.
Actually, this does not work. You need to call cmd.Root().GenFishCompletion(...).
There was a problem hiding this comment.
I just pushed a fix for this, this might have been a leftover of previous commits, where cmd was overwritten by cmd.Root()
Signed-off-by: Christophe Courtaut <[email protected]>
This allow to choose if descriptions in completions are generated for shells supporting it. Signed-off-by: Christophe Courtaut <[email protected]>
|
Because we're waiting for #8314 let's target the 3.4 release for this improvement. |
|
Hi @kri5. Just checking to see if you will have some time to work on the fish completion rebase. There's no real urgency since it's targeted for the 3.4 release but I just wanted to ask. Thanks. |
|
Hi @kri5. With 3.3 released, work has begun for helm 3.4. Will you be able to rebase this PR so we can provide fish completion? If you are unable to, I can take it over if you prefer? |
What this PR does / why we need it:
This PR delegates support for completion entirely to cobra.
This allows to support more shells without the need to maintain specific code on helm side.
closes #8109