Issue #412: When AddComment, update childs' parentsPflags

This commit is contained in:
aimof 2017-07-03 02:42:52 +09:00
parent 8c6fa02d22
commit 17f55c3af6

View file

@ -844,6 +844,13 @@ func (c *Command) AddCommand(cmds ...*Command) {
} }
c.commands = append(c.commands, x) c.commands = append(c.commands, x)
c.commandsAreSorted = false 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)
} }
} }