mirror of
https://github.com/spf13/cobra
synced 2025-05-07 13:57:21 +00:00
doc: add example code of generating Zsh completion
This commit is contained in:
parent
b04b5bfc50
commit
d234c0b441
1 changed files with 8 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue