mirror of
https://github.com/spf13/cobra
synced 2024-12-28 23:37:09 +00:00
Reuse GenBashCompletion in GenBashCompletionFile
This commit is contained in:
parent
463be1428d
commit
a5ff2f28ab
1 changed files with 1 additions and 9 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue