mirror of
https://github.com/spf13/cobra
synced 2024-11-05 05:17:12 +00:00
flags: clarify documentation that LocalFlags related function do not modify the state (#2064)
This commit is contained in:
parent
0dec88e793
commit
4fb0a66a34
1 changed files with 6 additions and 0 deletions
|
@ -154,8 +154,10 @@ type Command struct {
|
|||
// pflags contains persistent flags.
|
||||
pflags *flag.FlagSet
|
||||
// lflags contains local flags.
|
||||
// This field does not represent internal state, it's used as a cache to optimise LocalFlags function call
|
||||
lflags *flag.FlagSet
|
||||
// iflags contains inherited flags.
|
||||
// This field does not represent internal state, it's used as a cache to optimise InheritedFlags function call
|
||||
iflags *flag.FlagSet
|
||||
// parentsPflags is all persistent flags of cmd's parents.
|
||||
parentsPflags *flag.FlagSet
|
||||
|
@ -1659,6 +1661,7 @@ func (c *Command) Flags() *flag.FlagSet {
|
|||
}
|
||||
|
||||
// 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.
|
||||
func (c *Command) LocalNonPersistentFlags() *flag.FlagSet {
|
||||
persistentFlags := c.PersistentFlags()
|
||||
|
||||
|
@ -1672,6 +1675,7 @@ func (c *Command) LocalNonPersistentFlags() *flag.FlagSet {
|
|||
}
|
||||
|
||||
// LocalFlags returns the local FlagSet specifically set in the current command.
|
||||
// This function does not modify the flags of the current command, it's purpose is to return the current state.
|
||||
func (c *Command) LocalFlags() *flag.FlagSet {
|
||||
c.mergePersistentFlags()
|
||||
|
||||
|
@ -1699,6 +1703,7 @@ func (c *Command) LocalFlags() *flag.FlagSet {
|
|||
}
|
||||
|
||||
// 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.
|
||||
func (c *Command) InheritedFlags() *flag.FlagSet {
|
||||
c.mergePersistentFlags()
|
||||
|
||||
|
@ -1724,6 +1729,7 @@ func (c *Command) InheritedFlags() *flag.FlagSet {
|
|||
}
|
||||
|
||||
// NonInheritedFlags returns all flags which were not inherited from parent commands.
|
||||
// This function does not modify the flags of the current command, it's purpose is to return the current state.
|
||||
func (c *Command) NonInheritedFlags() *flag.FlagSet {
|
||||
return c.LocalFlags()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue