summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/spf13/cobra/zsh_completions.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/cobra/zsh_completions.go')
-rw-r--r--vendor/github.com/spf13/cobra/zsh_completions.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/vendor/github.com/spf13/cobra/zsh_completions.go b/vendor/github.com/spf13/cobra/zsh_completions.go
index b350aeeca..889c22e27 100644
--- a/vendor/github.com/spf13/cobra/zsh_completions.go
+++ b/vendor/github.com/spf13/cobra/zsh_completions.go
@@ -4,17 +4,29 @@ import (
"bytes"
"fmt"
"io"
+ "os"
"strings"
)
+// GenZshCompletionFile generates zsh completion file.
+func (c *Command) GenZshCompletionFile(filename string) error {
+ outFile, err := os.Create(filename)
+ if err != nil {
+ return err
+ }
+ defer outFile.Close()
+
+ return c.GenZshCompletion(outFile)
+}
+
// GenZshCompletion generates a zsh completion file and writes to the passed writer.
-func (cmd *Command) GenZshCompletion(w io.Writer) error {
+func (c *Command) GenZshCompletion(w io.Writer) error {
buf := new(bytes.Buffer)
- writeHeader(buf, cmd)
- maxDepth := maxDepth(cmd)
+ writeHeader(buf, c)
+ maxDepth := maxDepth(c)
writeLevelMapping(buf, maxDepth)
- writeLevelCases(buf, maxDepth, cmd)
+ writeLevelCases(buf, maxDepth, c)
_, err := buf.WriteTo(w)
return err