mirror of
https://github.com/spf13/cobra
synced 2025-04-27 17:17:20 +00:00
flags: clarify documentation that LocalFlags related function do not modify the state
This commit is contained in:
parent
637ba7bbc1
commit
51056406ff
1 changed files with 6 additions and 0 deletions
|
@ -154,8 +154,10 @@ type Command struct {
|
||||||
// pflags contains persistent flags.
|
// pflags contains persistent flags.
|
||||||
pflags *flag.FlagSet
|
pflags *flag.FlagSet
|
||||||
// lflags contains local flags.
|
// 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
|
lflags *flag.FlagSet
|
||||||
// iflags contains inherited flags.
|
// 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
|
iflags *flag.FlagSet
|
||||||
// parentsPflags is all persistent flags of cmd's parents.
|
// parentsPflags is all persistent flags of cmd's parents.
|
||||||
parentsPflags *flag.FlagSet
|
parentsPflags *flag.FlagSet
|
||||||
|
@ -1653,6 +1655,7 @@ func (c *Command) Flags() *flag.FlagSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalNonPersistentFlags are flags specific to this command which will NOT persist to subcommands.
|
// 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 {
|
func (c *Command) LocalNonPersistentFlags() *flag.FlagSet {
|
||||||
persistentFlags := c.PersistentFlags()
|
persistentFlags := c.PersistentFlags()
|
||||||
|
|
||||||
|
@ -1666,6 +1669,7 @@ func (c *Command) LocalNonPersistentFlags() *flag.FlagSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalFlags returns the local FlagSet specifically set in the current command.
|
// 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 {
|
func (c *Command) LocalFlags() *flag.FlagSet {
|
||||||
c.mergePersistentFlags()
|
c.mergePersistentFlags()
|
||||||
|
|
||||||
|
@ -1693,6 +1697,7 @@ func (c *Command) LocalFlags() *flag.FlagSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
// InheritedFlags returns all flags which were inherited from parent commands.
|
// 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 {
|
func (c *Command) InheritedFlags() *flag.FlagSet {
|
||||||
c.mergePersistentFlags()
|
c.mergePersistentFlags()
|
||||||
|
|
||||||
|
@ -1718,6 +1723,7 @@ func (c *Command) InheritedFlags() *flag.FlagSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NonInheritedFlags returns all flags which were not inherited from parent commands.
|
// 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 {
|
func (c *Command) NonInheritedFlags() *flag.FlagSet {
|
||||||
return c.LocalFlags()
|
return c.LocalFlags()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue