Documentation ¶
Overview ¶
Package flags is a simple cobra/viper-aware flag wrapper that creates a unified interface for flag addition and access. It supports only the types that iscenv needs, if you need more add them.
Index ¶
- func AddConfigFlag(cmd *cobra.Command, name string, value interface{}, usage string)
- func AddConfigFlagP(cmd *cobra.Command, name string, shorthand string, value interface{}, ...)
- func AddFlag(cmd *cobra.Command, name string, value interface{}, usage string)
- func AddFlagComplex(cmd *cobra.Command, persistent bool, cfg bool, name string, shorthand string, ...)
- func AddFlagP(cmd *cobra.Command, name string, shorthand string, value interface{}, ...)
- func GetBool(cmd *cobra.Command, name string) bool
- func GetFlagKey(cmd *cobra.Command, name string) string
- func GetInt(cmd *cobra.Command, name string) int
- func GetInt64(cmd *cobra.Command, name string) int64
- func GetKeys() []string
- func GetRawValue(key string) interface{}
- func GetString(cmd *cobra.Command, name string) string
- func GetStringSlice(cmd *cobra.Command, name string) []string
- func GetUint(cmd *cobra.Command, name string) uint
- func GetValue(cmd *cobra.Command, name string) interface{}
- func GetValueWithKey(key string) interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddConfigFlag ¶
AddConfigFlag adds a flag to the provided command that is also bound to a config value
func AddConfigFlagP ¶
func AddConfigFlagP(cmd *cobra.Command, name string, shorthand string, value interface{}, usage string)
AddConfigFlagP is like AddConfigFlag but accepts a shorthand letter that can be used after a single dash.
func AddFlagComplex ¶
func AddFlagComplex(cmd *cobra.Command, persistent bool, cfg bool, name string, shorthand string, value interface{}, usage string)
AddFlagComplex adds a flag to the provided cobra command. The default value will determine the type of flag. Supported types are: string, bool, int64, uint, []string
func AddFlagP ¶
AddFlagP is like AddFlag, but accepts a shorthand letter that can be used after a single dash
func GetFlagKey ¶
GetFlagKey returns the key for a flag given its name
func GetRawValue ¶
func GetRawValue(key string) interface{}
GetRawValue returns a flag value as the underlying interface without asserting a type
func GetStringSlice ¶
GetStringSlice returns a flag value by name as a string slice
func GetValueWithKey ¶
func GetValueWithKey(key string) interface{}
GetValueWithKey returns a flag value by key as an interface
Types ¶
This section is empty.