MCPcopy
hub / github.com/spf13/cobra / GenBashCompletion

Method GenBashCompletion

bash_completions.go:683–694  ·  view source on GitHub ↗

GenBashCompletion generates bash completion file and writes to the passed writer.

(w io.Writer)

Source from the content-addressed store, hash-verified

681
682// GenBashCompletion generates bash completion file and writes to the passed writer.
683func (c *Command) GenBashCompletion(w io.Writer) error {
684 buf := new(bytes.Buffer)
685 writePreamble(buf, c.Name())
686 if len(c.BashCompletionFunction) > 0 {
687 buf.WriteString(c.BashCompletionFunction + "\n")
688 }
689 gen(buf, c)
690 writePostscript(buf, c.Name())
691
692 _, err := buf.WriteTo(w)
693 return err
694}
695
696func nonCompletableFlag(flag *pflag.Flag) bool {
697 return flag.Hidden || len(flag.Deprecated) > 0

Calls 4

NameMethod · 0.95
writePreambleFunction · 0.85
genFunction · 0.85
writePostscriptFunction · 0.85