zsh-completion: completion should always parse the root command!
It was running on the command it was invoked from which caused some additional helpers (--help, --version) not to be generated.
This commit is contained in:
committed by
Steve Francia
parent
91e80cc4a4
commit
7ce08e227e
@ -84,13 +84,15 @@ func (c *Command) GenZshCompletionFile(filename string) error {
|
||||
return c.GenZshCompletion(outFile)
|
||||
}
|
||||
|
||||
// GenZshCompletion generates a zsh completion file and writes to the passed writer.
|
||||
// GenZshCompletion generates a zsh completion file and writes to the passed
|
||||
// writer. The completion always run on the root command regardless of the
|
||||
// command it was called from.
|
||||
func (c *Command) GenZshCompletion(w io.Writer) error {
|
||||
tmpl, err := template.New("Main").Funcs(funcMap).Parse(zshCompletionText)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating zsh completion template: %v", err)
|
||||
}
|
||||
return tmpl.Execute(w, c)
|
||||
return tmpl.Execute(w, c.Root())
|
||||
}
|
||||
|
||||
func generateZshCompletionFuncName(c *Command) string {
|
||||
|
Reference in New Issue
Block a user