mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
adding a GenZshCompletionFile function to mirror bash_completion
This commit is contained in:
parent
3c0b56b677
commit
90e60b7ddb
1 changed files with 12 additions and 0 deletions
|
@ -4,9 +4,21 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GenZshCompletionFile generates zsh completion file.
|
||||
func (cmd *Command) GenZshCompletionFile(filename string) error {
|
||||
outFile, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer outFile.Close()
|
||||
|
||||
return cmd.GenZshCompletion(outFile)
|
||||
}
|
||||
|
||||
// GenZshCompletion generates a zsh completion file and writes to the passed writer.
|
||||
func (cmd *Command) GenZshCompletion(w io.Writer) error {
|
||||
buf := new(bytes.Buffer)
|
||||
|
|
Loading…
Reference in a new issue