From 4de692c1eb1394aff41da8b05fff75bd74c7127c Mon Sep 17 00:00:00 2001 From: agmen Date: Tue, 5 Sep 2017 17:32:32 +0100 Subject: [PATCH] adding a GenZshCompletionFile function to mirror bash_completion (#529) --- zsh_completions.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/zsh_completions.go b/zsh_completions.go index b350aee..62ebf4d 100644 --- a/zsh_completions.go +++ b/zsh_completions.go @@ -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)