mirror of
https://github.com/spf13/cobra
synced 2025-05-05 21:07:24 +00:00
add cmdname to rootcmdname
This commit is contained in:
parent
8df42ed8a2
commit
ceddf29ec7
1 changed files with 3 additions and 2 deletions
|
@ -222,7 +222,7 @@ __%[1]s_handle_command()
|
|||
next_command="_${last_command}_${words[c]//:/__}"
|
||||
else
|
||||
if [[ $c -eq 0 ]]; then
|
||||
next_command="_root_command"
|
||||
next_command="_%[1]s_root_command"
|
||||
else
|
||||
next_command="_${words[c]//:/__}"
|
||||
fi
|
||||
|
@ -457,7 +457,7 @@ func gen(buf *bytes.Buffer, cmd *Command) {
|
|||
commandName = strings.Replace(commandName, ":", "__", -1)
|
||||
|
||||
if cmd.Root() == cmd {
|
||||
buf.WriteString(fmt.Sprint("_root_command()\n{\n"))
|
||||
buf.WriteString(fmt.Sprintf("_%s_root_command()\n{\n", commandName))
|
||||
} else {
|
||||
buf.WriteString(fmt.Sprintf("_%s()\n{\n", commandName))
|
||||
}
|
||||
|
@ -473,6 +473,7 @@ func gen(buf *bytes.Buffer, cmd *Command) {
|
|||
|
||||
// GenBashCompletion generates bash completion file and writes to the passed writer.
|
||||
func (c *Command) GenBashCompletion(w io.Writer) error {
|
||||
fmt.Println("called")
|
||||
buf := new(bytes.Buffer)
|
||||
writePreamble(buf, c.Name())
|
||||
if len(c.BashCompletionFunction) > 0 {
|
||||
|
|
Loading…
Add table
Reference in a new issue