Documentation ¶
Overview ¶
Package flagx provides additional flag functions.
Index ¶
- func FileExists(name string, value string, usage string) *string
- func FileExistsFlagSet(fs *flag.FlagSet, name string, value string, usage string) *string
- func FloatBetween(name string, value float64, usage string, minVal, maxVal float64, ...) *float64
- func FloatBetweenFlagSet(fs *flag.FlagSet, name string, value float64, usage string, ...) *float64
- func IntBetween(name string, value int, usage string, minVal, maxVal int) *int
- func IntBetweenFlagSet(fs *flag.FlagSet, name string, value int, usage string, minVal, maxVal int) *int
- func OneOf[T comparable](name string, value T, usage string, of ...T) *T
- func OneOfFlagSet[T comparable](fs *flag.FlagSet, name string, value T, usage string, of ...T) *T
- func Regexp(name string, value *regexp.Regexp, usage string) **regexp.Regexp
- func RegexpFlagSet(fs *flag.FlagSet, name string, value *regexp.Regexp, usage string) **regexp.Regexp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileExists ¶ added in v0.6.0
FileExists defines a string flag that represents an existing file. Returns an error if the file does not exist.
func FileExistsFlagSet ¶ added in v0.6.0
FileExistsFlagSet defines a string flag that represents an existing file. Returns an error if the file does not exist.
func FloatBetween ¶
func FloatBetween(name string, value float64, usage string, minVal, maxVal float64, incMin, incMax bool) *float64
FloatBetween defines a float flag with specified name, default value, usage string and bounds. incMin and incMax define whether min and max are included in the allowed values. The return value is the address of a float variable that stores the value of the flag.
func FloatBetweenFlagSet ¶
func FloatBetweenFlagSet(fs *flag.FlagSet, name string, value float64, usage string, minVal, maxVal float64, incMin, incMax bool) *float64
FloatBetweenFlagSet defines a float flag with specified name, default value, usage string and bounds. incMin and incMax define whether min and max are included in the allowed values. The return value is the address of a float variable that stores the value of the flag.
func IntBetween ¶
IntBetween defines an int flag with specified name, default value, usage string and bounds. The return value is the address of an int variable that stores the value of the flag.
func IntBetweenFlagSet ¶
func IntBetweenFlagSet(fs *flag.FlagSet, name string, value int, usage string, minVal, maxVal int) *int
IntBetweenFlagSet defines an int flag with specified name, default value, usage string and bounds. The return value is the address of an int variable that stores the value of the flag.
func OneOf ¶ added in v0.6.0
func OneOf[T comparable](name string, value T, usage string, of ...T) *T
OneOf defines a flag that must have one of the given values. The type must be one that can be read by fmt.Scan.
func OneOfFlagSet ¶ added in v0.6.0
func OneOfFlagSet[T comparable](fs *flag.FlagSet, name string, value T, usage string, of ...T) *T
OneOfFlagSet defines a flag that must have one of the given values. The type must be one that can be read by fmt.Scan.
func Regexp ¶
Regexp defines a regular expression flag with specified name, default value, and usage string. The return value is the address of a regular expression variable that stores the value of the flag.
func RegexpFlagSet ¶
func RegexpFlagSet(fs *flag.FlagSet, name string, value *regexp.Regexp, usage string) **regexp.Regexp
RegexpFlagSet defines a regular expression flag with specified name, default value, and usage string. The return value is the address of a regular expression variable that stores the value of the flag.
Types ¶
This section is empty.