MCPcopy
hub / github.com/spf13/cobra / InheritedFlags

Method InheritedFlags

command.go:1744–1766  ·  view source on GitHub ↗

InheritedFlags returns all flags which were inherited from parent commands. This function does not modify the flags of the current command, it's purpose is to return the current state.

()

Source from the content-addressed store, hash-verified

1742// InheritedFlags returns all flags which were inherited from parent commands.
1743// This function does not modify the flags of the current command, it's purpose is to return the current state.
1744func (c *Command) InheritedFlags() *flag.FlagSet {
1745 c.mergePersistentFlags()
1746
1747 if c.iflags == nil {
1748 c.iflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
1749 if c.flagErrorBuf == nil {
1750 c.flagErrorBuf = new(bytes.Buffer)
1751 }
1752 c.iflags.SetOutput(c.flagErrorBuf)
1753 }
1754
1755 local := c.LocalFlags()
1756 if c.globNormFunc != nil {
1757 c.iflags.SetNormalizeFunc(c.globNormFunc)
1758 }
1759
1760 c.parentsPflags.VisitAll(func(f *flag.Flag) {
1761 if c.iflags.Lookup(f.Name) == nil && local.Lookup(f.Name) == nil {
1762 c.iflags.AddFlag(f)
1763 }
1764 })
1765 return c.iflags
1766}
1767
1768// NonInheritedFlags returns all flags which were not inherited from parent commands.
1769// This function does not modify the flags of the current command, it's purpose is to return the current state.

Callers 13

getCompletionsMethod · 0.95
HasInheritedFlagsMethod · 0.95
completeRequireFlagsFunction · 0.80
findFlagFunction · 0.80
writeFlagsFunction · 0.80
defaultUsageFuncFunction · 0.80
manPrintOptionsFunction · 0.80
GenYamlCustomFunction · 0.80
printOptionsReSTFunction · 0.80

Calls 4

mergePersistentFlagsMethod · 0.95
DisplayNameMethod · 0.95
LocalFlagsMethod · 0.95
SetOutputMethod · 0.80