mirror of https://github.com/spf13/cobra.git
adding a GenZshCompletionFile function to mirror bash_completion (#529)
This commit is contained in:
parent
3c0b56b677
commit
4de692c1eb
|
@ -4,9 +4,21 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"strings"
|
"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.
|
// GenZshCompletion generates a zsh completion file and writes to the passed writer.
|
||||||
func (cmd *Command) GenZshCompletion(w io.Writer) error {
|
func (cmd *Command) GenZshCompletion(w io.Writer) error {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
Loading…
Reference in New Issue