Skip to content
Myr

flags: clarify documentation that LocalFlags related function do not modify the state (#2064)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Dmytro Milinevskyi · committed by GitHub · parent 0dec88e · Browse files · 1 file+6 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−0 removed

  • other:+6 added−0 removed

1 file+6 added−0 removed

modified:command.go+6 added
152 unmodified lines
153 flags *flag.FlagSet154 // pflags contains persistent flags.155 pflags *flag.FlagSet156 // lflags contains local flags.157 // This field does not represent internal state, it's used as a cache to optimise LocalFlags function call158 lflags *flag.FlagSet159 // iflags contains inherited flags.160 // This field does not represent internal state, it's used as a cache to optimise InheritedFlags function call161 iflags *flag.FlagSet162 // parentsPflags is all persistent flags of cmd's parents.163 parentsPflags *flag.FlagSet164 // globNormFunc is the global normalization function
1495 unmodified lines
1660 return c.flags1661}16621663// LocalNonPersistentFlags are flags specific to this command which will NOT persist to subcommands.1664// This function does not modify the flags of the current command, it's purpose is to return the current state.1665func (c *Command) LocalNonPersistentFlags() *flag.FlagSet {1666 persistentFlags := c.PersistentFlags()16671668 out := flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
5 unmodified lines
1674 return out1675}16761677// LocalFlags returns the local FlagSet specifically set in the current command.1678// This function does not modify the flags of the current command, it's purpose is to return the current state.1679func (c *Command) LocalFlags() *flag.FlagSet {1680 c.mergePersistentFlags()16811682 if c.lflags == nil {
19 unmodified lines
1702 return c.lflags1703}17041705// InheritedFlags returns all flags which were inherited from parent commands.1706// This function does not modify the flags of the current command, it's purpose is to return the current state.1707func (c *Command) InheritedFlags() *flag.FlagSet {1708 c.mergePersistentFlags()17091710 if c.iflags == nil {
17 unmodified lines
1728 return c.iflags1729}17301731// NonInheritedFlags returns all flags which were not inherited from parent commands.1732// This function does not modify the flags of the current command, it's purpose is to return the current state.1733func (c *Command) NonInheritedFlags() *flag.FlagSet {1734 return c.LocalFlags()1735}1736
161 unmodified lines