Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugEnabled ¶
func DebugEnabled() bool
DebugEnabled returns whether the debug is enabled or not
func Parse ¶
func Parse() error
Parse parses the command-line flags from env and os.Args[1:]. Value from env can be overrided by os.Args[1:]. This function also add ENVIRONMENT VARIABLE to usage. It is extremely recommended to call this function in main() after all flags are defined and before flags are accessed by the program. NOTICE: flag.Parse() will be called by this function.
func ProcessFlagWithEnv ¶
func ProcessFlagWithEnv() error
ProcessFlagWithEnv parses flag from env. This function also add ENVIRONMENT VARIABLE to usage. NOTICE: flag.Parse() will not be called by this function.
func SetEnvFlagDict ¶
SetEnvFlagDict sets a user-defined env-flag map for standard envflag.
func SetMinLength ¶
func SetMinLength(v int)
SetMinLength sets the min length for standard envflag. EnvFlag only parses the environment variables that is longer than min length and modify usage that is longer than min length.
func SetShowEnvKeyInUsage ¶
func SetShowEnvKeyInUsage(v bool)
SetShowEnvKeyInUsage sets whether show env key in usage for standard envflag.
func SetShowEnvValInUsage ¶
func SetShowEnvValInUsage(v bool)
SetShowEnvValInUsage sets whether show env value in usage for standard envflag. This is useful for confirming the environment variables.
Types ¶
type EnvFlag ¶
type EnvFlag struct {
// contains filtered or unexported fields
}
EnvFlag represents a envflag object that contains several settings.
func NewEnvFlag ¶
func NewEnvFlag( flagSet *flag.FlagSet, minLength int, envFlagDict map[string]string, showEnvKeyInUsage bool, showEnvValInUsage bool) *EnvFlag
NewEnvFlag returns a new EnvFlag.
func (EnvFlag) Parse ¶
Parse parses flag definitions from env and the argument list. Value from env can be overrided by the argument list. This function also add ENVIRONMENT VARIABLE to usage. It is extremely recommended to call this function in main() after all flags are defined and before flags are accessed by the program. NOTICE: flag.Parse() will be called by this function.
func (EnvFlag) ProcessFlagWithEnv ¶
ProcessFlagWithEnv parses flag from env. This function also add ENVIRONMENT VARIABLE to usage. NOTICE: flag.Parse() will not be called by this function.
func (*EnvFlag) SetEnvFlagDict ¶
SetEnvFlagDict sets a user-defined env-flag map.
func (*EnvFlag) SetMinLength ¶
SetMinLength sets the min length. EnvFlag only parses the environment variables that is longer than min length and modify usage that is longer than min length.
func (*EnvFlag) SetShowEnvKeyInUsage ¶
SetShowEnvKeyInUsage sets whether show env key in usage.
func (*EnvFlag) SetShowEnvValInUsage ¶
SetShowEnvValInUsage sets whether show env value in usage. This is useful for confirming the environment variables.