From 3e61377cd57a0aea7cddd366f77800033d5b5295 Mon Sep 17 00:00:00 2001 From: Albert Nigmatzianov Date: Wed, 19 Apr 2017 10:50:00 +0200 Subject: [PATCH] Use AddFlagSet instead of self-written function --- command.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/command.go b/command.go index f912736e..b4a6e668 100644 --- a/command.go +++ b/command.go @@ -1228,13 +1228,7 @@ func (c *Command) Parent() *Command { // mergePersistentFlags merges c.PersistentFlags() to c.Flags() // and adds missing persistent flags of all parents. func (c *Command) mergePersistentFlags() { - if c.HasPersistentFlags() { - c.PersistentFlags().VisitAll(func(f *flag.Flag) { - if c.Flags().Lookup(f.Name) == nil { - c.Flags().AddFlag(f) - } - }) - } + c.Flags().AddFlagSet(c.PersistentFlags()) added := c.updateParentsPflags() if len(added) > 0 {