mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
add new flag to lflags
This commit is contained in:
parent
dcb405a939
commit
8bff6aff17
1 changed files with 4 additions and 1 deletions
|
@ -1633,7 +1633,10 @@ 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) {
|
||||||
c.lflags.AddFlag(f)
|
newFlag := &flag.Flag{}
|
||||||
|
*newFlag = *f
|
||||||
|
newFlag.Changed = false
|
||||||
|
c.lflags.AddFlag(newFlag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.Flags().VisitAll(addToLocal)
|
c.Flags().VisitAll(addToLocal)
|
||||||
|
|
Loading…
Reference in a new issue