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) { addToLocal := func(f *flag.Flag) {
// Add the flag if it is not a parent PFlag, or it shadows a parent PFlag // 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) { if c.lflags.Lookup(f.Name) == nil && f != c.parentsPflags.Lookup(f.Name) {
newFlag := &flag.Flag{} f.Changed = false
*newFlag = *f c.lflags.AddFlag(f)
newFlag.Changed = false
c.lflags.AddFlag(newFlag)
} }
} }
c.Flags().VisitAll(addToLocal) c.Flags().VisitAll(addToLocal)