mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
Issue #412: When AddComment, update childs' parentsPflags
This commit is contained in:
parent
8c6fa02d22
commit
17f55c3af6
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.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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue