mirror of
https://github.com/spf13/cobra
synced 2025-05-06 05:17:21 +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]//:/__}"
|
next_command="_${last_command}_${words[c]//:/__}"
|
||||||
else
|
else
|
||||||
if [[ $c -eq 0 ]]; then
|
if [[ $c -eq 0 ]]; then
|
||||||
next_command="_root_command"
|
next_command="_%[1]s_root_command"
|
||||||
else
|
else
|
||||||
next_command="_${words[c]//:/__}"
|
next_command="_${words[c]//:/__}"
|
||||||
fi
|
fi
|
||||||
|
@ -457,7 +457,7 @@ func gen(buf *bytes.Buffer, cmd *Command) {
|
||||||
commandName = strings.Replace(commandName, ":", "__", -1)
|
commandName = strings.Replace(commandName, ":", "__", -1)
|
||||||
|
|
||||||
if cmd.Root() == cmd {
|
if cmd.Root() == cmd {
|
||||||
buf.WriteString(fmt.Sprint("_root_command()\n{\n"))
|
buf.WriteString(fmt.Sprintf("_%s_root_command()\n{\n", commandName))
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(fmt.Sprintf("_%s()\n{\n", commandName))
|
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.
|
// GenBashCompletion generates bash completion file and writes to the passed writer.
|
||||||
func (c *Command) GenBashCompletion(w io.Writer) error {
|
func (c *Command) GenBashCompletion(w io.Writer) error {
|
||||||
|
fmt.Println("called")
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
writePreamble(buf, c.Name())
|
writePreamble(buf, c.Name())
|
||||||
if len(c.BashCompletionFunction) > 0 {
|
if len(c.BashCompletionFunction) > 0 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue