flagx

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package flagx provides additional flag functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists added in v0.6.0

func FileExists(name string, value string, usage string) *string

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

func FileExistsFlagSet(fs *flag.FlagSet, name string, value string,
	usage string) *string

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

func IntBetween(name string, value int, usage string, minVal, maxVal int) *int

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

func Regexp(name string, value *regexp.Regexp, usage string) **regexp.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL