mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
Use AddFlagSet instead of self-written function
This commit is contained in:
parent
458d79748e
commit
3e61377cd5
1 changed files with 1 additions and 7 deletions
|
@ -1228,13 +1228,7 @@ func (c *Command) Parent() *Command {
|
||||||
// mergePersistentFlags merges c.PersistentFlags() to c.Flags()
|
// mergePersistentFlags merges c.PersistentFlags() to c.Flags()
|
||||||
// and adds missing persistent flags of all parents.
|
// and adds missing persistent flags of all parents.
|
||||||
func (c *Command) mergePersistentFlags() {
|
func (c *Command) mergePersistentFlags() {
|
||||||
if c.HasPersistentFlags() {
|
c.Flags().AddFlagSet(c.PersistentFlags())
|
||||||
c.PersistentFlags().VisitAll(func(f *flag.Flag) {
|
|
||||||
if c.Flags().Lookup(f.Name) == nil {
|
|
||||||
c.Flags().AddFlag(f)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
added := c.updateParentsPflags()
|
added := c.updateParentsPflags()
|
||||||
if len(added) > 0 {
|
if len(added) > 0 {
|
||||||
|
|
Loading…
Reference in a new issue