mirror of
https://github.com/spf13/cobra
synced 2025-05-05 21:07:24 +00:00
Merge 17f55c3af6
into 8c6fa02d22
This commit is contained in:
commit
847cf63062
1 changed files with 7 additions and 0 deletions
|
@ -844,6 +844,13 @@ func (c *Command) AddCommand(cmds ...*Command) {
|
|||
}
|
||||
c.commands = append(c.commands, x)
|
||||
c.commandsAreSorted = false
|
||||
if cmds[i].parentsPflags == nil {
|
||||
cmds[i].parentsPflags = flag.NewFlagSet(cmds[i].Name(), flag.ContinueOnError)
|
||||
cmds[i].parentsPflags.SetOutput(c.flagErrorBuf)
|
||||
cmds[i].parentsPflags.SortFlags = false
|
||||
}
|
||||
cmds[i].parentsPflags.AddFlagSet(c.PersistentFlags())
|
||||
cmds[i].Flags().AddFlagSet(cmds[i].parentsPflags)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue