From a5ff2f28ab3732401608da7b5fa5da7069662f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 3 Jan 2016 14:45:11 +0100 Subject: [PATCH] Reuse GenBashCompletion in GenBashCompletionFile --- bash_completions.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/bash_completions.go b/bash_completions.go index f6bd1a4..00f97eb 100644 --- a/bash_completions.go +++ b/bash_completions.go @@ -1,7 +1,6 @@ package cobra import ( - "bytes" "fmt" "io" "os" @@ -390,20 +389,13 @@ func (cmd *Command) GenBashCompletion(w io.Writer) { } func (cmd *Command) GenBashCompletionFile(filename string) error { - out := new(bytes.Buffer) - - cmd.GenBashCompletion(out) - outFile, err := os.Create(filename) if err != nil { return err } defer outFile.Close() - _, err = outFile.Write(out.Bytes()) - if err != nil { - return err - } + cmd.GenBashCompletion(outFile) return nil }