Documentation ¶
Index ¶
- func GetBoolFlagValue(cmd *cobra.Command, flag BoolFlag) bool
- func GetBoolPersistentFlagValue(cmd *cobra.Command, flag BoolFlag) bool
- func GetIntFlagValue(cmd *cobra.Command, flag IntFlag) int
- func GetIntPersistentFlagValue(cmd *cobra.Command, flag IntFlag) int
- func GetIntSliceFlagValue(cmd *cobra.Command, flag IntSliceFlag) []int
- func GetIntSlicePersistentFlagValue(cmd *cobra.Command, flag IntSliceFlag) []int
- func GetStringFlagValue(cmd *cobra.Command, flag StringFlag) string
- func GetStringPersistentFlagValue(cmd *cobra.Command, flag StringFlag) string
- func GetStringSliceFlagValue(cmd *cobra.Command, flag StringSliceFlag) []string
- func GetStringSlicePersistentFlagValue(cmd *cobra.Command, flag StringSliceFlag) []string
- func HasFlagsChanged(cmd *cobra.Command, flags []Flag) bool
- func IsFlagChanged(cmd *cobra.Command, flag Flag) bool
- func RegisterFlags(cmd *cobra.Command, flags []Flag) error
- func RegisterPFlags(cmd *cobra.Command, flags []Flag) error
- func SetParseErrorHandle(f errorHandle)
- type BoolFlag
- type Flag
- type IntFlag
- type IntSliceFlag
- type StringFlag
- type StringSliceFlag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBoolFlagValue ¶
GetBoolFlagValue get the bool value for the given BoolFlag from the local flags of the cobra command.
func GetBoolPersistentFlagValue ¶
GetBoolPersistentFlagValue get the bool value for the given BoolFlag from the persistent flags of the given cobra command.
func GetIntFlagValue ¶
GetIntFlagValue get the int value for the given IntFlag from the local flags of the cobra command.
func GetIntPersistentFlagValue ¶
GetIntPersistentFlagValue get the int value for the given IntFlag from the persistent flags of the cobra command.
func GetIntSliceFlagValue ¶
func GetIntSliceFlagValue(cmd *cobra.Command, flag IntSliceFlag) []int
GetIntSliceFlagValue get the int slice value for the given IntSliceFlag from the local flags of the cobra command.
func GetIntSlicePersistentFlagValue ¶
func GetIntSlicePersistentFlagValue(cmd *cobra.Command, flag IntSliceFlag) []int
GetIntSlicePersistentFlagValue get the int slice value for the given IntSliceFlag from the persistent flags of the cobra command.
func GetStringFlagValue ¶
func GetStringFlagValue(cmd *cobra.Command, flag StringFlag) string
GetStringFlagValue get the string value for the given StringFlag from the local flags of the cobra command.
func GetStringPersistentFlagValue ¶
func GetStringPersistentFlagValue(cmd *cobra.Command, flag StringFlag) string
GetStringPersistentFlagValue get the string value for the given StringFlag from the persistent flags of the cobra command.
func GetStringSliceFlagValue ¶
func GetStringSliceFlagValue(cmd *cobra.Command, flag StringSliceFlag) []string
GetStringSliceFlagValue get the string slice value for the given StringSliceFlag from the local flags of the cobra command.
func GetStringSlicePersistentFlagValue ¶
func GetStringSlicePersistentFlagValue(cmd *cobra.Command, flag StringSliceFlag) []string
GetStringSlicePersistentFlagValue get the string slice value for the given StringSliceFlag from the persistent flags of the cobra command.
func HasFlagsChanged ¶
HasFlagsChanged returns whether any of the flags is set by user in the command
func IsFlagChanged ¶
IsFlagChanged returns whether the flag has been changed in command
func RegisterFlags ¶
RegisterFlags register the flags to command's local flag
func RegisterPFlags ¶
RegisterPFlags register the flags to command's persistent flag
func SetParseErrorHandle ¶
func SetParseErrorHandle(f errorHandle)
SetParseErrorHandle set the error handle function used for cli parsing flags. An error handle example:
cli.SetParseErrorHandle(func(err error) { fmt.Println(err) os.Exit(3) })
Types ¶
type BoolFlag ¶
type BoolFlag struct { Name string Shorthand string Usage string Deprecated string Hidden bool DefValue bool }
BoolFlag is the flag with boolean value
type Flag ¶
Flag is the interface for cli flags. To get the value after cli parsing, use fs.GetString(flag.Name)
type IntFlag ¶
type IntFlag struct { Name string Shorthand string Usage string Deprecated string Hidden bool DefValue int }
IntFlag is the flag with int value
type IntSliceFlag ¶
type IntSliceFlag struct { Name string Shorthand string Usage string Deprecated string Hidden bool DefValue []int }
IntSliceFlag is the flag with int slice value
func (IntSliceFlag) RegisterTo ¶
func (f IntSliceFlag) RegisterTo(fs *pflag.FlagSet) error
RegisterTo register the string slice flag to FlagSet
type StringFlag ¶
type StringFlag struct { Name string Shorthand string Usage string Deprecated string Hidden bool DefValue string }
StringFlag is the flag with string value
func (StringFlag) RegisterTo ¶
func (f StringFlag) RegisterTo(fs *pflag.FlagSet) error
RegisterTo register the string flag to FlagSet
type StringSliceFlag ¶
type StringSliceFlag struct { Name string Shorthand string Usage string Deprecated string Hidden bool DefValue []string }
StringSliceFlag is the flag with string slice value
func (StringSliceFlag) RegisterTo ¶
func (f StringSliceFlag) RegisterTo(fs *pflag.FlagSet) error
RegisterTo register the string slice flag to FlagSet