Documentation ¶
Index ¶
- Constants
- Variables
- func BindFlags(cmd *cobra.Command)
- func ConvertToMap(fs *pflag.FlagSet) map[string]string
- func CopyFlagValue(sourceFlagName, destinationFlagName string, fs *pflag.FlagSet, ...) error
- func CreateCommandFlags(cmd *cobra.Command, cs config.ConfigurationSet) error
- func CreateFlagsFromConfig(cs config.ConfigurationSet) (*pflag.FlagSet, error)
- func ExistsWithValue(name string, flags *pflag.FlagSet) bool
- func GetFlagValueDirect(args []string, longName, shortName string) (string, error)
- func ParseFlagMultiValueToMap(flag string) map[string]string
- func PopulateConfigFromCommand(cmd *cobra.Command, cs config.ConfigurationSet)
- func PopulateConfigFromFlags(flags *pflag.FlagSet, cs config.ConfigurationSet)
- func Unmarshal(flagset *pflag.FlagSet, out interface{}, opts ...BinderOption) error
- type BinderOption
Constants ¶
View Source
const (
// TagName defines the name of struct tag to look for
TagName = "flag"
)
Variables ¶
View Source
var ( ErrMustBePtr = errors.New("must marshall into a pointer") ErrNilStruct = errors.New("cannot unmarshall flags into nil structure") ErrRequireStruct = errors.New(("must unmarshall into struct")) ErrFieldNotAddressable = errors.New("field cannot be set as its not addressable") ErrFlagNotFound = errors.New("flag not found in flagset") ErrUnsupportedType = errors.New("type not supported for unmarshalling") )
View Source
var ( // ErrFlagMissing is an error when there is no flag with a given name ErrFlagMissing = errors.New("flag missing") )
Functions ¶
func ConvertToMap ¶
ConvertToMap will convert a flagset to a map
func CopyFlagValue ¶
func CreateCommandFlags ¶
func CreateCommandFlags(cmd *cobra.Command, cs config.ConfigurationSet) error
func CreateFlagsFromConfig ¶
func CreateFlagsFromConfig(cs config.ConfigurationSet) (*pflag.FlagSet, error)
CreateFlagsFromConfig will create a FlagSet from a configuration set
func ExistsWithValue ¶
ExistsWithValue returns true if a flag exists in a flagset and has a value and that value is non-empty
func GetFlagValueDirect ¶
GetFlagValueDirect will get a flag value directly from args or config. Note: this should only be used in exceptional circumstances
func PopulateConfigFromCommand ¶
func PopulateConfigFromCommand(cmd *cobra.Command, cs config.ConfigurationSet)
func PopulateConfigFromFlags ¶
func PopulateConfigFromFlags(flags *pflag.FlagSet, cs config.ConfigurationSet)
Types ¶
type BinderOption ¶
type BinderOption func(*flagBinder)
BinderOption defines a functional option for creations of the flags binder
func IgnoreFlagNotFound ¶
func IgnoreFlagNotFound() BinderOption
IgnoreFlagNotFound is an option that specifies that if a flag doesn't exist then no error should be returned
Click to show internal directories.
Click to hide internal directories.