changed so that flags in c.lflags refer to flags in c.flags

This commit is contained in:
Jun Nishimura 2023-07-22 17:25:36 +09:00
parent f15758ac15
commit c67af4c687

View file

@ -1632,10 +1632,8 @@ func (c *Command) LocalFlags() *flag.FlagSet {
addToLocal := func(f *flag.Flag) {
// Add the flag if it is not a parent PFlag, or it shadows a parent PFlag
if c.lflags.Lookup(f.Name) == nil && f != c.parentsPflags.Lookup(f.Name) {
newFlag := &flag.Flag{}
*newFlag = *f
newFlag.Changed = false
c.lflags.AddFlag(newFlag)
f.Changed = false
c.lflags.AddFlag(f)
}
}
c.Flags().VisitAll(addToLocal)