Documentation ¶
Index ¶
- func Bind(flags FlagSet, config interface{}, isDev bool, opts ...BindOpt)
- func BindSetup(flags FlagSet, config interface{}, isDev bool, opts ...BindOpt)
- func DevFlag(cmd *cobra.Command, dest *bool, value bool, usage string)
- func FindConfigDirParam() string
- func FindFlagEarly(flagName string) string
- func FindIdentityDirParam() string
- func SetupFlag(log *zap.Logger, cmd *cobra.Command, dest *string, name, value, usage string)
- type BindOpt
- type FlagSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bind ¶
Bind sets flags on a FlagSet that match the configuration struct 'config'. This works by traversing the config struct using the 'reflect' package. Will ignore fields with `setup:"true"` tag.
func BindSetup ¶
BindSetup sets flags on a FlagSet that match the configuration struct 'config'. This works by traversing the config struct using the 'reflect' package.
func FindConfigDirParam ¶
func FindConfigDirParam() string
FindConfigDirParam returns '--config-dir' param from os.Args (if exists)
func FindFlagEarly ¶
FindFlagEarly retrieves the value of a flag before `flag.Parse` has been called
func FindIdentityDirParam ¶
func FindIdentityDirParam() string
FindIdentityDirParam returns '--identity-dir' param from os.Args (if exists)
Types ¶
type BindOpt ¶
type BindOpt func(vars map[string]confVar)
BindOpt is an option for the Bind method
func ConfDirNested ¶
ConfDirNested sets variables for default options called $CONFDIR and $CONFNAME. ConfDirNested also appends the parent struct field name to the paths before descending into substructs.
func IdentityDir ¶
IdentityDir sets a variable for the default option called $IDENTITYDIR.
type FlagSet ¶
type FlagSet interface { BoolVar(p *bool, name string, value bool, usage string) IntVar(p *int, name string, value int, usage string) Int64Var(p *int64, name string, value int64, usage string) UintVar(p *uint, name string, value uint, usage string) Uint64Var(p *uint64, name string, value uint64, usage string) DurationVar(p *time.Duration, name string, value time.Duration, usage string) Float64Var(p *float64, name string, value float64, usage string) StringVar(p *string, name string, value string, usage string) Var(val pflag.Value, name string, usage string) }
FlagSet is an interface that matches *pflag.FlagSet