doc: add example code of generating Zsh completion

This commit is contained in:
autopp 2019-12-24 09:37:17 +09:00
parent b04b5bfc50
commit d234c0b441

View file

@ -4,6 +4,14 @@ Cobra supports native Zsh completion generated from the root `cobra.Command`.
The generated completion script should be put somewhere in your `$fpath` named
`_<YOUR COMMAND>`.
```go
// Output to given io.Writer
rootCmd.GenZshCompletion(os.Stdout)
// Output to given file
rootCmd.GenZshCompletionFile("/path/to/fpath/_your_command")
```
### What's Supported
* Completion for all non-hidden subcommands using their `.Short` description.