Documentation ¶
Index ¶
- func Add(flag Flag)
- func AutoEnv(fn func(long string) (env string))
- func Bool(short string, long string, value bool, usage string) *bool
- func BoolVar(ptr *bool, short string, long string, value bool, usage string)
- func Bytes(short string, long string, value []byte, usage string) *[]byte
- func BytesVar(ptr *[]byte, short string, long string, value []byte, usage string)
- func Config(fn func(*os.File) error)
- func Duration(short string, long string, value time.Duration, usage string) *time.Duration
- func DurationVar(ptr *time.Duration, short string, long string, value time.Duration, ...)
- func Float(short string, long string, value float64, usage string) *float64
- func FloatSlice(short string, long string, value []float64, usage string) *[]float64
- func FloatSliceVar(ptr *[]float64, short string, long string, value []float64, usage string)
- func FloatVar(ptr *float64, short string, long string, value float64, usage string)
- func Func(short string, long string, usage string, fn func())
- func Help()
- func Int(short string, long string, value int, usage string) *int
- func Int64(short string, long string, value int64, usage string) *int64
- func Int64Slice(short string, long string, value []int64, usage string) *[]int64
- func Int64SliceVar(ptr *[]int64, short string, long string, value []int64, usage string)
- func Int64Var(ptr *int64, short string, long string, value int64, usage string)
- func IntSlice(short string, long string, value []int, usage string) *[]int
- func IntSliceVar(ptr *[]int, short string, long string, value []int, usage string)
- func IntVar(ptr *int, short string, long string, value int, usage string)
- func MustParse() (unused []string)
- func Parse() (unused []string, err error)
- func ParseArgs() (unused []string, err error)
- func ParseEnv() (err error)
- func Reset()
- func Size(short string, long string, value bytesize.Size, usage string) *bytesize.Size
- func SizeVar(ptr *bytesize.Size, short string, long string, value bytesize.Size, ...)
- func String(short string, long string, value string, usage string) *string
- func StringSlice(short string, long string, value []string, usage string) *[]string
- func StringSliceVar(ptr *[]string, short string, long string, value []string, usage string)
- func StringVar(ptr *string, short string, long string, value string, usage string)
- func StructFields(dst interface{})
- func Uint(short string, long string, value uint, usage string) *uint
- func Uint64(short string, long string, value uint64, usage string) *uint64
- func Uint64Slice(short string, long string, value []uint64, usage string) *[]uint64
- func Uint64SliceVar(ptr *[]uint64, short string, long string, value []uint64, usage string)
- func Uint64Var(ptr *uint64, short string, long string, value uint64, usage string)
- func UintSlice(short string, long string, value []uint, usage string) *[]uint
- func UintSliceVar(ptr *[]uint, short string, long string, value []uint, usage string)
- func UintVar(ptr *uint, short string, long string, value uint, usage string)
- func Usage() string
- func Var(ptr Value, short string, long string, value string, usage string)
- func Version(version string)
- type Flag
- type FlagSet
- func (set *FlagSet) Add(flag Flag)
- func (set *FlagSet) AutoEnv(fn func(long string) (env string))
- func (set *FlagSet) Bool(short string, long string, value bool, usage string) *bool
- func (set *FlagSet) BoolSlice(short string, long string, value []bool, usage string) *[]bool
- func (set *FlagSet) BoolSliceVar(ptr *[]bool, short string, long string, value []bool, usage string)
- func (set *FlagSet) BoolVar(ptr *bool, short string, long string, value bool, usage string)
- func (set *FlagSet) Bytes(short string, long string, value []byte, usage string) *[]byte
- func (set *FlagSet) BytesVar(ptr *[]byte, short string, long string, value []byte, usage string)
- func (set *FlagSet) Config(fn func(*os.File) error)
- func (set *FlagSet) Duration(short string, long string, value time.Duration, usage string) *time.Duration
- func (set *FlagSet) DurationSlice(short string, long string, value []time.Duration, usage string) *[]time.Duration
- func (set *FlagSet) DurationSliceVar(ptr *[]time.Duration, short string, long string, value []time.Duration, ...)
- func (set *FlagSet) DurationVar(ptr *time.Duration, short string, long string, value time.Duration, ...)
- func (set *FlagSet) Float(short string, long string, value float64, usage string) *float64
- func (set *FlagSet) FloatSlice(short string, long string, value []float64, usage string) *[]float64
- func (set *FlagSet) FloatSliceVar(ptr *[]float64, short string, long string, value []float64, usage string)
- func (set *FlagSet) FloatVar(ptr *float64, short string, long string, value float64, usage string)
- func (set *FlagSet) Func(short string, long string, usage string, fn func())
- func (set *FlagSet) GetEnv(name string) *Flag
- func (set *FlagSet) GetLong(name string) *Flag
- func (set *FlagSet) GetShort(name string) *Flag
- func (set *FlagSet) Help()
- func (set *FlagSet) Hook(fn func())
- func (set *FlagSet) Int(short string, long string, value int, usage string) *int
- func (set *FlagSet) Int64(short string, long string, value int64, usage string) *int64
- func (set *FlagSet) Int64Slice(short string, long string, value []int64, usage string) *[]int64
- func (set *FlagSet) Int64SliceVar(ptr *[]int64, short string, long string, value []int64, usage string)
- func (set *FlagSet) Int64Var(ptr *int64, short string, long string, value int64, usage string)
- func (set *FlagSet) IntSlice(short string, long string, value []int, usage string) *[]int
- func (set *FlagSet) IntSliceVar(ptr *[]int, short string, long string, value []int, usage string)
- func (set *FlagSet) IntVar(ptr *int, short string, long string, value int, usage string)
- func (set *FlagSet) MustParse(args, env []string) (unused []string)
- func (set *FlagSet) Parse(args, env []string) (unused []string, err error)
- func (set *FlagSet) ParseArgs(args []string) (unused []string, err error)
- func (set *FlagSet) ParseEnv(env []string) (err error)
- func (set *FlagSet) Reset()
- func (set *FlagSet) Size(short string, long string, value bytesize.Size, usage string) *bytesize.Size
- func (set *FlagSet) SizeSlice(short string, long string, value []bytesize.Size, usage string) *[]bytesize.Size
- func (set *FlagSet) SizeSliceVar(ptr *[]bytesize.Size, short string, long string, value []bytesize.Size, ...)
- func (set *FlagSet) SizeVar(ptr *bytesize.Size, short string, long string, value bytesize.Size, ...)
- func (set *FlagSet) Sort()
- func (set *FlagSet) String(short string, long string, value string, usage string) *string
- func (set *FlagSet) StringSlice(short string, long string, value []string, usage string) *[]string
- func (set *FlagSet) StringSliceVar(ptr *[]string, short string, long string, value []string, usage string)
- func (set *FlagSet) StringVar(ptr *string, short string, long string, value string, usage string)
- func (set *FlagSet) StructFields(dst any)
- func (set *FlagSet) Uint(short string, long string, value uint, usage string) *uint
- func (set *FlagSet) Uint64(short string, long string, value uint64, usage string) *uint64
- func (set *FlagSet) Uint64Slice(short string, long string, value []uint64, usage string) *[]uint64
- func (set *FlagSet) Uint64SliceVar(ptr *[]uint64, short string, long string, value []uint64, usage string)
- func (set *FlagSet) Uint64Var(ptr *uint64, short string, long string, value uint64, usage string)
- func (set *FlagSet) UintSlice(short string, long string, value []uint, usage string) *[]uint
- func (set *FlagSet) UintSliceVar(ptr *[]uint, short string, long string, value []uint, usage string)
- func (set *FlagSet) UintVar(ptr *uint, short string, long string, value uint, usage string)
- func (set *FlagSet) Usage() string
- func (set *FlagSet) Var(ptr Value, short string, long string, value string, usage string)
- func (set *FlagSet) Version(version string)
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DurationVar ¶
func FloatSlice ¶
func FloatSliceVar ¶
func Int64SliceVar ¶
func IntSliceVar ¶
func StringSlice ¶
func StringSliceVar ¶
func StructFields ¶
func StructFields(dst interface{})
func Uint64Slice ¶
func Uint64SliceVar ¶
func UintSliceVar ¶
Types ¶
type Flag ¶
type Flag struct { // Short is the short-form flag name, parsed from CLI flags prefixed by '-'. Short string // Long is the long-form flag name, parsed from CLI flags prefixed by '--'. Long string // Env ... Env string // Usage is the description for this CLI flag, used when generating usage string. Usage string // Required specifies whether this flag is required, if so returning error. Required bool // Default is the default value for this CLI flag, used when no value provided. Default string // RawValues contains raw value strings populated during parse stage. RawValues []string // Value stores the actual value pointer that is set upon argument parsing. Value Value }
func (Flag) AppendUsage ¶
AppendUsage will append (new-line terminated) usage information for flag to b.
type FlagSet ¶
type FlagSet struct {
// contains filtered or unexported fields
}
var Global FlagSet
Global provides access to a global FlagSet instance accessible via global FlagSet functions below.
func (*FlagSet) AutoEnv ¶
AutoEnv will automatically assign environment keys to flags with a long-name provided, if nil will use a default function.
func (*FlagSet) BoolSliceVar ¶
func (*FlagSet) Config ¶
Config registers a function hook to open path and pass to given 'fn' on supplied '-c' or '--config' value.
func (*FlagSet) DurationSlice ¶
func (*FlagSet) DurationSliceVar ¶
func (*FlagSet) DurationVar ¶
func (*FlagSet) FloatSlice ¶
func (*FlagSet) FloatSliceVar ¶
func (*FlagSet) Func ¶
Func registers a function hook to be called on boolean result = true of given short,long,env Flag.
func (*FlagSet) Help ¶
func (set *FlagSet) Help()
Help registers a function hook to print usage string and exit with code = 0 on '-h' or '--help'.
func (*FlagSet) Hook ¶
func (set *FlagSet) Hook(fn func())
Hook allows registering a function hook to be called directly after parse.
func (*FlagSet) Int64Slice ¶
func (*FlagSet) Int64SliceVar ¶
func (*FlagSet) IntSliceVar ¶
func (*FlagSet) Parse ¶
Parse parses environment variables, followed by CLI arguments, into FlagSet, returning unused arguments.
func (*FlagSet) ParseArgs ¶
ParseArgs parses CLI arguments from slices into FlagSet, returning unused arguments.
func (*FlagSet) SizeSliceVar ¶
func (*FlagSet) Sort ¶
func (set *FlagSet) Sort()
Sort will sort the internal slice of flags, first by short name, then long name.
func (*FlagSet) StringSlice ¶
func (*FlagSet) StringSliceVar ¶
func (*FlagSet) StructFields ¶
StructFields registers appropriately tagged struct fields as flags.
Tags: "short" - the flag short name "long" - the flag long name "env" - flag env key name "usage" - the flag usage information "default" - the default flag value (in string form) "required" - whether flag MUST be provided
func (*FlagSet) Uint64Slice ¶
func (*FlagSet) Uint64SliceVar ¶
func (*FlagSet) UintSliceVar ¶
func (*FlagSet) Usage ¶
Usage returns a string showing typical terminal-formatted usage information for all of the registered flags.