Reuse GenBashCompletion in GenBashCompletionFile
This commit is contained in:
		@ -1,7 +1,6 @@
 | 
				
			|||||||
package cobra
 | 
					package cobra
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
					 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
@ -390,20 +389,13 @@ func (cmd *Command) GenBashCompletion(w io.Writer) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (cmd *Command) GenBashCompletionFile(filename string) error {
 | 
					func (cmd *Command) GenBashCompletionFile(filename string) error {
 | 
				
			||||||
	out := new(bytes.Buffer)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cmd.GenBashCompletion(out)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	outFile, err := os.Create(filename)
 | 
						outFile, err := os.Create(filename)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	defer outFile.Close()
 | 
						defer outFile.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_, err = outFile.Write(out.Bytes())
 | 
						cmd.GenBashCompletion(outFile)
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user