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

Method LocalNonPersistentFlags

command.go:1702–1712  ·  view source on GitHub ↗

LocalNonPersistentFlags are flags specific to this command which will NOT persist to subcommands. 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

1700// LocalNonPersistentFlags are flags specific to this command which will NOT persist to subcommands.
1701// This function does not modify the flags of the current command, it's purpose is to return the current state.
1702func (c *Command) LocalNonPersistentFlags() *flag.FlagSet {
1703 persistentFlags := c.PersistentFlags()
1704
1705 out := flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
1706 c.LocalFlags().VisitAll(func(f *flag.Flag) {
1707 if persistentFlags.Lookup(f.Name) == nil {
1708 out.AddFlag(f)
1709 }
1710 })
1711 return out
1712}
1713
1714// LocalFlags returns the local FlagSet specifically set in the current command.
1715// This function does not modify the flags of the current command, it's purpose is to return the current state.

Callers 2

getCompletionsMethod · 0.95
writeFlagsFunction · 0.80

Calls 3

PersistentFlagsMethod · 0.95
DisplayNameMethod · 0.95
LocalFlagsMethod · 0.95

Tested by

no test coverage detected