mirror of
https://github.com/spf13/cobra
synced 2025-05-05 21:07:24 +00:00
inherited flags use parent's normalization function
This commit is contained in:
parent
cdd5a8d607
commit
7ed3585bd8
1 changed files with 5 additions and 0 deletions
|
@ -1157,6 +1157,7 @@ func (c *Command) InheritedFlags() *flag.FlagSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
local := c.LocalFlags()
|
local := c.LocalFlags()
|
||||||
|
c.iflags.SetNormalizeFunc(c.parentsPflags.GetNormalizeFunc())
|
||||||
|
|
||||||
c.parentsPflags.VisitAll(func(f *flag.Flag) {
|
c.parentsPflags.VisitAll(func(f *flag.Flag) {
|
||||||
if c.iflags.Lookup(f.Name) == nil && local.Lookup(f.Name) == nil {
|
if c.iflags.Lookup(f.Name) == nil && local.Lookup(f.Name) == nil {
|
||||||
|
@ -1300,6 +1301,10 @@ func (c *Command) updateParentsPflags() {
|
||||||
c.parentsPflags.SortFlags = false
|
c.parentsPflags.SortFlags = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.HasParent() {
|
||||||
|
c.parentsPflags.SetNormalizeFunc(c.Parent().PersistentFlags().GetNormalizeFunc())
|
||||||
|
}
|
||||||
|
|
||||||
c.Root().PersistentFlags().AddFlagSet(flag.CommandLine)
|
c.Root().PersistentFlags().AddFlagSet(flag.CommandLine)
|
||||||
|
|
||||||
c.VisitParents(func(parent *Command) {
|
c.VisitParents(func(parent *Command) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue