Merge pull request #75 from eparis/CommandLine

Make flags declared outside spf13.pflag persistent flags on the parent
This commit is contained in:
Eric Paris 2015-04-30 10:20:35 -05:00
commit 2d5fab043c

View file

@ -948,6 +948,13 @@ func (c *Command) mergePersistentFlags() {
c.PersistentFlags().VisitAll(addtolocal)
}
rmerge = func(x *Command) {
if ! x.HasParent() {
flag.CommandLine.VisitAll(func(f *flag.Flag) {
if x.PersistentFlags().Lookup(f.Name) == nil {
x.PersistentFlags().AddFlag(f)
}
})
}
if x.HasPersistentFlags() {
x.PersistentFlags().VisitAll(func(f *flag.Flag) {
if c.Flags().Lookup(f.Name) == nil {