Documentation
¶
Overview ¶
Package values provides implementations of flag.Value and primitives to register them.
Aside of RegistererFunc, there is 30 functions declaring various flag.Value. Their names are matched by this regular expression:
(Generic|Basic|Stringer|Time|Duration)(List|Slice)?(Var)?
If neither 'List' nor 'Slice' are present, then the value is parsed and stored to a variable. Multiple sets will overwrite the value.
If 'List' is present, the value is then a slice and can be set multiple times.
If 'Slice' is present, the value is also a slice, but all its values are set at once every time the flag is invoked. The flag.Value will split the input string and parse the substrings.
If 'Var' is present, the function accepts another pointer parameter which will be used to store the parsed values.
On top of 'Generic', several flag.Value variants are implemented to simplify common use-cases:
- 'Basic' for Go's basic types (int, uint64, float64, string, ...)
- 'Stringer' for object imlementing fmt.Stringer (*url.URL, netip.Addr, ...)
- 'Time' takes a layout for use in time.Time.Format and time.Parse
- 'Duration' for time.Duration values
The values shall then be registered using flag.FlagSet.Var.
Index ¶
- func Basic[T basic]() flag.Value
- func BasicList[T basic]() flag.Value
- func BasicListVar[T basic](p *[]T) flag.Value
- func BasicSlice[T basic](sep string) flag.Value
- func BasicSliceVar[T basic](p *[]T, sep string) flag.Value
- func BasicVar[T basic](p *T) flag.Value
- func Duration() flag.Value
- func DurationList() flag.Value
- func DurationListVar(p *[]time.Duration) flag.Value
- func DurationSlice(sep string) flag.Value
- func DurationSliceVar(p *[]time.Duration, sep string) flag.Value
- func DurationVar(p *time.Duration) flag.Value
- func Generic[T any](parse func(string) (T, error), format func(T) string) flag.Value
- func GenericList[T any](parse func(string) (T, error), format func(T) string) flag.Value
- func GenericListVar[T any](p *[]T, parse func(string) (T, error), format func(T) string) flag.Value
- func GenericSlice[T any](sep string, parse func(string) (T, error), format func(T) string) flag.Value
- func GenericSliceVar[T any](p *[]T, sep string, parse func(string) (T, error), format func(T) string) flag.Value
- func GenericVar[T any](p *T, parse func(string) (T, error), format func(T) string) flag.Value
- func Stringer[T fmt.Stringer](parse func(string) (T, error)) flag.Value
- func StringerList[T fmt.Stringer](parse func(string) (T, error)) flag.Value
- func StringerListVar[T fmt.Stringer](p *[]T, parse func(string) (T, error)) flag.Value
- func StringerSlice[T fmt.Stringer](sep string, parse func(string) (T, error)) flag.Value
- func StringerSliceVar[T fmt.Stringer](p *[]T, sep string, parse func(string) (T, error)) flag.Value
- func StringerVar[T fmt.Stringer](p *T, parse func(string) (T, error)) flag.Value
- func Time(layout string) flag.Value
- func TimeList(layout string) flag.Value
- func TimeListVar(p *[]time.Time, layout string) flag.Value
- func TimeSlice(sep string, layout string) flag.Value
- func TimeSliceVar(p *[]time.Time, sep string, layout string) flag.Value
- func TimeVar(p *time.Time, layout string) flag.Value
- type RegistererFunc
- func (f RegistererFunc) Bool(name string, value bool, usage string) *bool
- func (f RegistererFunc) BoolList(name string, value []bool, usage string) *[]bool
- func (f RegistererFunc) BoolListVar(p *[]bool, name string, value []bool, usage string)
- func (f RegistererFunc) BoolSlice(name string, value []bool, sep string, usage string) *[]bool
- func (f RegistererFunc) BoolSliceVar(p *[]bool, name string, value []bool, sep string, usage string)
- func (f RegistererFunc) BoolVar(p *bool, name string, value bool, usage string)
- func (f RegistererFunc) Complex64(name string, value complex64, usage string) *complex64
- func (f RegistererFunc) Complex64List(name string, value []complex64, usage string) *[]complex64
- func (f RegistererFunc) Complex64ListVar(p *[]complex64, name string, value []complex64, usage string)
- func (f RegistererFunc) Complex64Slice(name string, value []complex64, sep string, usage string) *[]complex64
- func (f RegistererFunc) Complex64SliceVar(p *[]complex64, name string, value []complex64, sep string, usage string)
- func (f RegistererFunc) Complex64Var(p *complex64, name string, value complex64, usage string)
- func (f RegistererFunc) Complex128(name string, value complex128, usage string) *complex128
- func (f RegistererFunc) Complex128List(name string, value []complex128, usage string) *[]complex128
- func (f RegistererFunc) Complex128ListVar(p *[]complex128, name string, value []complex128, usage string)
- func (f RegistererFunc) Complex128Slice(name string, value []complex128, sep string, usage string) *[]complex128
- func (f RegistererFunc) Complex128SliceVar(p *[]complex128, name string, value []complex128, sep string, usage string)
- func (f RegistererFunc) Complex128Var(p *complex128, name string, value complex128, usage string)
- func (f RegistererFunc) Duration(name string, value time.Duration, usage string) *time.Duration
- func (f RegistererFunc) DurationList(name string, value []time.Duration, usage string) *[]time.Duration
- func (f RegistererFunc) DurationListVar(p *[]time.Duration, name string, value []time.Duration, usage string)
- func (f RegistererFunc) DurationSlice(name string, value []time.Duration, sep string, usage string) *[]time.Duration
- func (f RegistererFunc) DurationSliceVar(p *[]time.Duration, name string, value []time.Duration, sep string, ...)
- func (f RegistererFunc) DurationVar(p *time.Duration, name string, value time.Duration, usage string)
- func (f RegistererFunc) Float32(name string, value float32, usage string) *float32
- func (f RegistererFunc) Float32List(name string, value []float32, usage string) *[]float32
- func (f RegistererFunc) Float32ListVar(p *[]float32, name string, value []float32, usage string)
- func (f RegistererFunc) Float32Slice(name string, value []float32, sep string, usage string) *[]float32
- func (f RegistererFunc) Float32SliceVar(p *[]float32, name string, value []float32, sep string, usage string)
- func (f RegistererFunc) Float32Var(p *float32, name string, value float32, usage string)
- func (f RegistererFunc) Float64(name string, value float64, usage string) *float64
- func (f RegistererFunc) Float64List(name string, value []float64, usage string) *[]float64
- func (f RegistererFunc) Float64ListVar(p *[]float64, name string, value []float64, usage string)
- func (f RegistererFunc) Float64Slice(name string, value []float64, sep string, usage string) *[]float64
- func (f RegistererFunc) Float64SliceVar(p *[]float64, name string, value []float64, sep string, usage string)
- func (f RegistererFunc) Float64Var(p *float64, name string, value float64, usage string)
- func (f RegistererFunc) IPAddr(name string, value netip.Addr, usage string) *netip.Addr
- func (f RegistererFunc) IPAddrList(name string, value []netip.Addr, usage string) *[]netip.Addr
- func (f RegistererFunc) IPAddrListVar(p *[]netip.Addr, name string, value []netip.Addr, usage string)
- func (f RegistererFunc) IPAddrPort(name string, value netip.AddrPort, usage string) *netip.AddrPort
- func (f RegistererFunc) IPAddrPortList(name string, value []netip.AddrPort, usage string) *[]netip.AddrPort
- func (f RegistererFunc) IPAddrPortListVar(p *[]netip.AddrPort, name string, value []netip.AddrPort, usage string)
- func (f RegistererFunc) IPAddrPortSlice(name string, value []netip.AddrPort, sep string, usage string) *[]netip.AddrPort
- func (f RegistererFunc) IPAddrPortSliceVar(p *[]netip.AddrPort, name string, value []netip.AddrPort, sep string, ...)
- func (f RegistererFunc) IPAddrPortVar(p *netip.AddrPort, name string, value netip.AddrPort, usage string)
- func (f RegistererFunc) IPAddrSlice(name string, value []netip.Addr, sep string, usage string) *[]netip.Addr
- func (f RegistererFunc) IPAddrSliceVar(p *[]netip.Addr, name string, value []netip.Addr, sep string, usage string)
- func (f RegistererFunc) IPAddrVar(p *netip.Addr, name string, value netip.Addr, usage string)
- func (f RegistererFunc) IPPrefix(name string, value netip.Prefix, usage string) *netip.Prefix
- func (f RegistererFunc) IPPrefixList(name string, value []netip.Prefix, usage string) *[]netip.Prefix
- func (f RegistererFunc) IPPrefixListVar(p *[]netip.Prefix, name string, value []netip.Prefix, usage string)
- func (f RegistererFunc) IPPrefixSlice(name string, value []netip.Prefix, sep string, usage string) *[]netip.Prefix
- func (f RegistererFunc) IPPrefixSliceVar(p *[]netip.Prefix, name string, value []netip.Prefix, sep string, usage string)
- func (f RegistererFunc) IPPrefixVar(p *netip.Prefix, name string, value netip.Prefix, usage string)
- func (f RegistererFunc) Int(name string, value int, usage string) *int
- func (f RegistererFunc) Int8(name string, value int8, usage string) *int8
- func (f RegistererFunc) Int8List(name string, value []int8, usage string) *[]int8
- func (f RegistererFunc) Int8ListVar(p *[]int8, name string, value []int8, usage string)
- func (f RegistererFunc) Int8Slice(name string, value []int8, sep string, usage string) *[]int8
- func (f RegistererFunc) Int8SliceVar(p *[]int8, name string, value []int8, sep string, usage string)
- func (f RegistererFunc) Int8Var(p *int8, name string, value int8, usage string)
- func (f RegistererFunc) Int16(name string, value int16, usage string) *int16
- func (f RegistererFunc) Int16List(name string, value []int16, usage string) *[]int16
- func (f RegistererFunc) Int16ListVar(p *[]int16, name string, value []int16, usage string)
- func (f RegistererFunc) Int16Slice(name string, value []int16, sep string, usage string) *[]int16
- func (f RegistererFunc) Int16SliceVar(p *[]int16, name string, value []int16, sep string, usage string)
- func (f RegistererFunc) Int16Var(p *int16, name string, value int16, usage string)
- func (f RegistererFunc) Int32(name string, value int32, usage string) *int32
- func (f RegistererFunc) Int32List(name string, value []int32, usage string) *[]int32
- func (f RegistererFunc) Int32ListVar(p *[]int32, name string, value []int32, usage string)
- func (f RegistererFunc) Int32Slice(name string, value []int32, sep string, usage string) *[]int32
- func (f RegistererFunc) Int32SliceVar(p *[]int32, name string, value []int32, sep string, usage string)
- func (f RegistererFunc) Int32Var(p *int32, name string, value int32, usage string)
- func (f RegistererFunc) Int64(name string, value int64, usage string) *int64
- func (f RegistererFunc) Int64List(name string, value []int64, usage string) *[]int64
- func (f RegistererFunc) Int64ListVar(p *[]int64, name string, value []int64, usage string)
- func (f RegistererFunc) Int64Slice(name string, value []int64, sep string, usage string) *[]int64
- func (f RegistererFunc) Int64SliceVar(p *[]int64, name string, value []int64, sep string, usage string)
- func (f RegistererFunc) Int64Var(p *int64, name string, value int64, usage string)
- func (f RegistererFunc) IntList(name string, value []int, usage string) *[]int
- func (f RegistererFunc) IntListVar(p *[]int, name string, value []int, usage string)
- func (f RegistererFunc) IntSlice(name string, value []int, sep string, usage string) *[]int
- func (f RegistererFunc) IntSliceVar(p *[]int, name string, value []int, sep string, usage string)
- func (f RegistererFunc) IntVar(p *int, name string, value int, usage string)
- func (f RegistererFunc) MailAddr(name string, value *mail.Address, usage string) **mail.Address
- func (f RegistererFunc) MailAddrList(name string, value []*mail.Address, usage string) *[]*mail.Address
- func (f RegistererFunc) MailAddrListVar(p *[]*mail.Address, name string, value []*mail.Address, usage string)
- func (f RegistererFunc) MailAddrSlice(name string, value []*mail.Address, sep string, usage string) *[]*mail.Address
- func (f RegistererFunc) MailAddrSliceVar(p *[]*mail.Address, name string, value []*mail.Address, sep string, ...)
- func (f RegistererFunc) MailAddrVar(p **mail.Address, name string, value *mail.Address, usage string)
- func (f RegistererFunc) String(name string, value string, usage string) *string
- func (f RegistererFunc) StringList(name string, value []string, usage string) *[]string
- func (f RegistererFunc) StringListVar(p *[]string, name string, value []string, usage string)
- func (f RegistererFunc) StringSlice(name string, value []string, sep string, usage string) *[]string
- func (f RegistererFunc) StringSliceVar(p *[]string, name string, value []string, sep string, usage string)
- func (f RegistererFunc) StringVar(p *string, name string, value string, usage string)
- func (f RegistererFunc) Time(name string, value time.Time, layout string, usage string) *time.Time
- func (f RegistererFunc) TimeList(name string, value []time.Time, layout string, usage string) *[]time.Time
- func (f RegistererFunc) TimeListVar(p *[]time.Time, name string, value []time.Time, layout string, usage string)
- func (f RegistererFunc) TimeSlice(name string, value []time.Time, sep string, layout string, usage string) *[]time.Time
- func (f RegistererFunc) TimeSliceVar(p *[]time.Time, name string, value []time.Time, sep string, layout string, ...)
- func (f RegistererFunc) TimeVar(p *time.Time, name string, value time.Time, layout string, usage string)
- func (f RegistererFunc) URL(name string, value *url.URL, usage string) **url.URL
- func (f RegistererFunc) URLList(name string, value []*url.URL, usage string) *[]*url.URL
- func (f RegistererFunc) URLListVar(p *[]*url.URL, name string, value []*url.URL, usage string)
- func (f RegistererFunc) URLSlice(name string, value []*url.URL, sep string, usage string) *[]*url.URL
- func (f RegistererFunc) URLSliceVar(p *[]*url.URL, name string, value []*url.URL, sep string, usage string)
- func (f RegistererFunc) URLVar(p **url.URL, name string, value *url.URL, usage string)
- func (f RegistererFunc) Uint(name string, value uint, usage string) *uint
- func (f RegistererFunc) Uint8(name string, value uint8, usage string) *uint8
- func (f RegistererFunc) Uint8List(name string, value []uint8, usage string) *[]uint8
- func (f RegistererFunc) Uint8ListVar(p *[]uint8, name string, value []uint8, usage string)
- func (f RegistererFunc) Uint8Slice(name string, value []uint8, sep string, usage string) *[]uint8
- func (f RegistererFunc) Uint8SliceVar(p *[]uint8, name string, value []uint8, sep string, usage string)
- func (f RegistererFunc) Uint8Var(p *uint8, name string, value uint8, usage string)
- func (f RegistererFunc) Uint16(name string, value uint16, usage string) *uint16
- func (f RegistererFunc) Uint16List(name string, value []uint16, usage string) *[]uint16
- func (f RegistererFunc) Uint16ListVar(p *[]uint16, name string, value []uint16, usage string)
- func (f RegistererFunc) Uint16Slice(name string, value []uint16, sep string, usage string) *[]uint16
- func (f RegistererFunc) Uint16SliceVar(p *[]uint16, name string, value []uint16, sep string, usage string)
- func (f RegistererFunc) Uint16Var(p *uint16, name string, value uint16, usage string)
- func (f RegistererFunc) Uint32(name string, value uint32, usage string) *uint32
- func (f RegistererFunc) Uint32List(name string, value []uint32, usage string) *[]uint32
- func (f RegistererFunc) Uint32ListVar(p *[]uint32, name string, value []uint32, usage string)
- func (f RegistererFunc) Uint32Slice(name string, value []uint32, sep string, usage string) *[]uint32
- func (f RegistererFunc) Uint32SliceVar(p *[]uint32, name string, value []uint32, sep string, usage string)
- func (f RegistererFunc) Uint32Var(p *uint32, name string, value uint32, usage string)
- func (f RegistererFunc) Uint64(name string, value uint64, usage string) *uint64
- func (f RegistererFunc) Uint64List(name string, value []uint64, usage string) *[]uint64
- func (f RegistererFunc) Uint64ListVar(p *[]uint64, name string, value []uint64, usage string)
- func (f RegistererFunc) Uint64Slice(name string, value []uint64, sep string, usage string) *[]uint64
- func (f RegistererFunc) Uint64SliceVar(p *[]uint64, name string, value []uint64, sep string, usage string)
- func (f RegistererFunc) Uint64Var(p *uint64, name string, value uint64, usage string)
- func (f RegistererFunc) UintList(name string, value []uint, usage string) *[]uint
- func (f RegistererFunc) UintListVar(p *[]uint, name string, value []uint, usage string)
- func (f RegistererFunc) UintSlice(name string, value []uint, sep string, usage string) *[]uint
- func (f RegistererFunc) UintSliceVar(p *[]uint, name string, value []uint, sep string, usage string)
- func (f RegistererFunc) UintVar(p *uint, name string, value uint, usage string)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Basic ¶
Basic declares a flag.Value for Go [basic] types. The actual value type is T.
Example (Usage) ¶
package main
import (
"flag"
"os"
"github.com/rlibaert/flag/values"
)
func main() {
fs := flag.NewFlagSet("test", flag.ContinueOnError)
c := 12 + 42i
fs.Var(values.Basic[complex128](), "complex", "usage")
fs.Var(values.BasicVar(&c), "complex-var", "usage")
fs.Var(values.BasicList[complex128](), "complex-list", "usage")
fs.Var(values.BasicListVar(&[]complex128{c, c}), "complex-list-var", "usage")
fs.Var(values.BasicSlice[complex128](","), "complex-slice", "usage")
fs.Var(values.BasicSliceVar(&[]complex128{c, c}, ","), "complex-slice-var", "usage")
fs.SetOutput(os.Stdout)
fs.PrintDefaults()
}
Output: -complex value usage -complex-list value usage -complex-list-var value usage (default [(12+42i) (12+42i)]) -complex-slice value usage -complex-slice-var value usage (default (12+42i),(12+42i)) -complex-var value usage (default (12+42i))
func BasicList ¶
BasicList declares a list-style flag.Value for Go [basic] types. The actual value type is []T.
func BasicListVar ¶
BasicListVar is like BasicList but stores the values in p.
func BasicSlice ¶
BasicSlice declares a slice-style flag.Value for Go [basic] types. The input strings are split around sep before parsing. The actual value type is []T.
func BasicSliceVar ¶
BasicSliceVar is like BasicSlice but stores the values in p.
func Duration ¶
Duration declares a flag.Value for a single time.Duration value. The actual value type is time.Duration.
Example (Usage) ¶
package main
import (
"flag"
"os"
"time"
"github.com/rlibaert/flag/values"
)
func main() {
fs := flag.NewFlagSet("test", flag.ContinueOnError)
d := 1234 * time.Second
fs.Var(values.Duration(), "duration", "usage")
fs.Var(values.DurationVar(&d), "duration-var", "usage")
fs.Var(values.DurationList(), "duration-list", "usage")
fs.Var(values.DurationListVar(&[]time.Duration{d, d}), "duration-list-var", "usage")
fs.Var(values.DurationSlice(","), "duration-slice", "usage")
fs.Var(values.DurationSliceVar(&[]time.Duration{d, d}, ","), "duration-slice-var", "usage")
fs.SetOutput(os.Stdout)
fs.PrintDefaults()
}
Output: -duration value usage -duration-list value usage -duration-list-var value usage (default [20m34s 20m34s]) -duration-slice value usage -duration-slice-var value usage (default 20m34s,20m34s) -duration-var value usage (default 20m34s)
func DurationList ¶
DurationList declares a list-style flag.Value for multiple time.Duration values. The actual value type is []time.Duration.
func DurationListVar ¶
DurationListVar is like DurationList but stores the values in p.
func DurationSlice ¶
DurationSlice declares a slice-style flag.Value for multiple time.Duration values. The input strings are split around sep before parsing. The actual value type is []time.Duration.
func DurationSliceVar ¶
DurationSliceVar is like DurationSlice but stores the values in p.
func DurationVar ¶
DurationVar is like Duration but stores the value in p.
func Generic ¶
Generic declares a flag.Value implemented using the parse & format functions. The actual value type is T.
Example (Usage) ¶
package main
import (
"flag"
"os"
"strings"
"github.com/rlibaert/flag/values"
)
func main() {
type pair struct{ a, b string }
parse := func(s string) (pair, error) { a, b, _ := strings.Cut(s, ":"); return pair{a, b}, nil }
format := func(p pair) string { return p.a + ":" + p.b }
fs := flag.NewFlagSet("test", flag.ContinueOnError)
fs.Var(values.Generic(parse, format), "generic", "usage")
fs.Var(values.GenericVar(&pair{"foo", "bar"}, parse, format), "generic-var", "usage")
fs.Var(values.GenericList(parse, format), "generic-list", "usage")
fs.Var(values.GenericListVar(&[]pair{{"foo", "bar"}, {"quu", "quux"}}, parse, format), "generic-list-var", "usage")
fs.Var(values.GenericSlice(",", parse, format), "generic-slice", "usage")
fs.Var(values.GenericSliceVar(&[]pair{{"foo", "bar"}, {"quu", "quux"}}, ",", parse, format), "generic-slice-var", "usage") //nolint: golines
fs.SetOutput(os.Stdout)
fs.PrintDefaults()
}
Output: -generic value usage -generic-list value usage -generic-list-var value usage (default [foo:bar quu:quux]) -generic-slice value usage -generic-slice-var value usage (default foo:bar,quu:quux) -generic-var value usage (default foo:bar)
func GenericList ¶
GenericList declares a list-style flag.Value implemented using the parse & format functions. The actual value type is []T.
func GenericListVar ¶
GenericListVar is like GenericList but stores the values in p.
func GenericSlice ¶
func GenericSlice[T any](sep string, parse func(string) (T, error), format func(T) string) flag.Value
GenericSlice declares a slice-style flag.Value implemented using the parse & format functions. The input strings are split around sep before parsing. The actual value type is []T.
func GenericSliceVar ¶
func GenericSliceVar[T any](p *[]T, sep string, parse func(string) (T, error), format func(T) string) flag.Value
GenericSliceVar is like GenericSlice but stores the values in p.
func GenericVar ¶
GenericVar is like Generic but stores the value in p.
func Stringer ¶
Stringer declares a flag.Value implemented using the parse function and String method of a fmt.Stringer. The actual value type is T.
Example (Usage) ¶
package main
import (
"flag"
"net/netip"
"os"
"github.com/rlibaert/flag/values"
)
func main() {
fs := flag.NewFlagSet("test", flag.ContinueOnError)
ip := netip.MustParseAddr("1.2.3.4")
fs.Var(values.Stringer(netip.ParseAddr), "ip", "usage")
fs.Var(values.StringerVar(&ip, netip.ParseAddr), "ip-var", "usage")
fs.Var(values.StringerList(netip.ParseAddr), "ip-list", "usage")
fs.Var(values.StringerListVar(&[]netip.Addr{ip, ip}, netip.ParseAddr), "ip-list-var", "usage")
fs.Var(values.StringerSlice(",", netip.ParseAddr), "ip-slice", "usage")
fs.Var(values.StringerSliceVar(&[]netip.Addr{ip, ip}, ",", netip.ParseAddr), "ip-slice-var", "usage")
fs.SetOutput(os.Stdout)
fs.PrintDefaults()
}
Output: -ip value usage -ip-list value usage -ip-list-var value usage (default [1.2.3.4 1.2.3.4]) -ip-slice value usage -ip-slice-var value usage (default 1.2.3.4,1.2.3.4) -ip-var value usage (default 1.2.3.4)
Example (Usage2) ¶
package main
import (
"flag"
"net/url"
"os"
"github.com/rlibaert/flag/values"
)
func main() {
fs := flag.NewFlagSet("test", flag.ContinueOnError)
u := &url.URL{Scheme: "foo", Path: "bar"}
fs.Var(values.Stringer(url.Parse), "url", "usage")
fs.Var(values.StringerVar(&u, url.Parse), "url-var", "usage")
fs.Var(values.StringerList(url.Parse), "url-list", "usage")
fs.Var(values.StringerListVar(&[]*url.URL{u, u}, url.Parse), "url-list-var", "usage")
fs.Var(values.StringerSlice(",", url.Parse), "url-slice", "usage")
fs.Var(values.StringerSliceVar(&[]*url.URL{u, u}, ",", url.Parse), "url-slice-var", "usage")
fs.SetOutput(os.Stdout)
fs.PrintDefaults()
}
Output: -url value usage -url-list value usage -url-list-var value usage (default [foo://bar foo://bar]) -url-slice value usage -url-slice-var value usage (default foo://bar,foo://bar) -url-var value usage (default foo://bar)
func StringerList ¶
StringerList declares a list-style flag.Value implemented using the parse function and String method of a fmt.Stringer. The actual value type is []T.
func StringerListVar ¶
StringerListVar is like StringerList but stores the values in p.
func StringerSlice ¶
StringerSlice declares a slice-style flag.Value implemented using the parse function and String method of a fmt.Stringer. The input strings are split around sep before parsing. The actual value type is []T.
func StringerSliceVar ¶
StringerSliceVar is like StringerSlice but stores the values in p.
func StringerVar ¶
StringerVar is like Stringer but store the value in p.
func Time ¶
Time declares a flag.Value for a single time.Time value, using layout for parsing and formatting. The actual value type is time.Time.
Example (Usage) ¶
package main
import (
"flag"
"os"
"time"
"github.com/rlibaert/flag/values"
)
func main() {
fs := flag.NewFlagSet("test", flag.ContinueOnError)
t := time.Date(2025, 2, 1, 12, 34, 56, 0, time.UTC)
fs.Var(values.Time(time.RFC3339), "time", "usage")
fs.Var(values.TimeVar(&t, time.RFC3339), "time-var", "usage")
fs.Var(values.TimeList(time.RFC3339), "time-list", "usage")
fs.Var(values.TimeListVar(&[]time.Time{t, t}, time.RFC3339), "time-list-var", "usage")
fs.Var(values.TimeSlice(",", time.RFC3339), "time-slice", "usage")
fs.Var(values.TimeSliceVar(&[]time.Time{t, t}, ",", time.RFC3339), "time-slice-var", "usage")
fs.SetOutput(os.Stdout)
fs.PrintDefaults()
}
Output: -time value usage -time-list value usage -time-list-var value usage (default [2025-02-01T12:34:56Z 2025-02-01T12:34:56Z]) -time-slice value usage -time-slice-var value usage (default 2025-02-01T12:34:56Z,2025-02-01T12:34:56Z) -time-var value usage (default 2025-02-01T12:34:56Z)
func TimeList ¶
TimeList declares a list-style flag.Value for multiple time.Time values, using layout for parsing and formatting. The actual value type is []time.Time.
func TimeListVar ¶
TimeListVar is like TimeList but stores the values in p.
func TimeSlice ¶
TimeSlice declares a slice-style flag.Value for multiple time.Time values, using layout for parsing and formatting. The input strings are split around sep before parsing. The actual value type is []time.Time.
func TimeSliceVar ¶
TimeSliceVar is like TimeSlice but stores the values in p.
Types ¶
type RegistererFunc ¶
RegistererFunc is a function that registers a named flag.Value with a usage string. It provides an convenient interface analogous to *flag.FlagSet for defining flags for common types.
func FlagSetEnvRegisterer ¶
func FlagSetEnvRegisterer(fs *flag.FlagSet, prefix string) RegistererFunc
FlagSetEnvRegisterer returns a RegistererFunc that registers named flags in a flag.FlagSet and sets the flag.Value with the matching environment variable, ajusting usage accordingly.
The environment variable name is derived from the flag name by:
- replacing dashes and dots with underscores
- transforming to upper case
- prepending with given prefix
The environment variable is ignored if it fails to set the flag value.
Example ¶
package main
import (
"flag"
"fmt"
"os"
"github.com/rlibaert/flag/values"
)
func main() {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.SetOutput(os.Stdout)
os.Setenv("FOO_INT", "42")
values.FlagSetEnvRegisterer(fs, "FOO_").Int("int", 12, "an int")
fmt.Println(fs.Lookup("int").DefValue, fs.Lookup("int").Value)
fs.Usage()
}
Output: 12 42 Usage: -int value an int (env $FOO_INT) (default 12)
func FlagSetRegisterer ¶
func FlagSetRegisterer(fs *flag.FlagSet) RegistererFunc
FlagSetRegisterer returns a RegistererFunc that registers named flags in a flag.FlagSet.
func (RegistererFunc) Bool ¶
func (f RegistererFunc) Bool(name string, value bool, usage string) *bool
Bool defines a bool flag with specified name, default value, and usage string. The return value is the address of a bool variable that stores the value of the flag.
func (RegistererFunc) BoolList ¶
func (f RegistererFunc) BoolList(name string, value []bool, usage string) *[]bool
BoolList defines a list-style bool flag with specified name, default value, and usage string. The return value is the address of a bool slice that stores the values of the flag.
func (RegistererFunc) BoolListVar ¶
func (f RegistererFunc) BoolListVar(p *[]bool, name string, value []bool, usage string)
BoolListVar defines a list-style bool flag with specified name, default value, and usage string. The argument p points to a bool slice variable in which to store the value of the flag.
func (RegistererFunc) BoolSlice ¶
BoolSlice defines a slice-style bool flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a bool slice that stores the values of the flag.
func (RegistererFunc) BoolSliceVar ¶
func (f RegistererFunc) BoolSliceVar(p *[]bool, name string, value []bool, sep string, usage string)
BoolSliceVar defines a slice-style bool flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a bool slice variable in which to store the value of the flag.
func (RegistererFunc) BoolVar ¶
func (f RegistererFunc) BoolVar(p *bool, name string, value bool, usage string)
BoolVar defines a bool flag with specified name, default value, and usage string. The argument p points to a bool variable in which to store the value of the flag.
func (RegistererFunc) Complex64 ¶
func (f RegistererFunc) Complex64(name string, value complex64, usage string) *complex64
Complex64 defines a complex64 flag with specified name, default value, and usage string. The return value is the address of a complex64 variable that stores the value of the flag.
func (RegistererFunc) Complex64List ¶
func (f RegistererFunc) Complex64List(name string, value []complex64, usage string) *[]complex64
Complex64List defines a list-style complex64 flag with specified name, default value, and usage string. The return value is the address of a complex64 slice that stores the values of the flag.
func (RegistererFunc) Complex64ListVar ¶
func (f RegistererFunc) Complex64ListVar(p *[]complex64, name string, value []complex64, usage string)
Complex64ListVar defines a list-style complex64 flag with specified name, default value, and usage string. The argument p points to a complex64 slice variable in which to store the value of the flag.
func (RegistererFunc) Complex64Slice ¶
func (f RegistererFunc) Complex64Slice(name string, value []complex64, sep string, usage string) *[]complex64
Complex64Slice defines a slice-style complex64 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a complex64 slice that stores the values of the flag.
func (RegistererFunc) Complex64SliceVar ¶
func (f RegistererFunc) Complex64SliceVar(p *[]complex64, name string, value []complex64, sep string, usage string)
Complex64SliceVar defines a slice-style complex64 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a complex64 slice variable in which to store the value of the flag.
func (RegistererFunc) Complex64Var ¶
func (f RegistererFunc) Complex64Var(p *complex64, name string, value complex64, usage string)
Complex64Var defines a complex64 flag with specified name, default value, and usage string. The argument p points to a complex64 variable in which to store the value of the flag.
func (RegistererFunc) Complex128 ¶
func (f RegistererFunc) Complex128(name string, value complex128, usage string) *complex128
Complex128 defines a complex128 flag with specified name, default value, and usage string. The return value is the address of a complex128 variable that stores the value of the flag.
func (RegistererFunc) Complex128List ¶
func (f RegistererFunc) Complex128List(name string, value []complex128, usage string) *[]complex128
Complex128List defines a list-style complex128 flag with specified name, default value, and usage string. The return value is the address of a complex128 slice that stores the values of the flag.
func (RegistererFunc) Complex128ListVar ¶
func (f RegistererFunc) Complex128ListVar(p *[]complex128, name string, value []complex128, usage string)
Complex128ListVar defines a list-style complex128 flag with specified name, default value, and usage string. The argument p points to a complex128 slice variable in which to store the value of the flag.
func (RegistererFunc) Complex128Slice ¶
func (f RegistererFunc) Complex128Slice(name string, value []complex128, sep string, usage string) *[]complex128
Complex128Slice defines a slice-style complex128 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a complex128 slice that stores the values of the flag.
func (RegistererFunc) Complex128SliceVar ¶
func (f RegistererFunc) Complex128SliceVar(p *[]complex128, name string, value []complex128, sep string, usage string)
Complex128SliceVar defines a slice-style complex128 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a complex128 slice variable in which to store the value of the flag.
func (RegistererFunc) Complex128Var ¶
func (f RegistererFunc) Complex128Var(p *complex128, name string, value complex128, usage string)
Complex128Var defines a complex128 flag with specified name, default value, and usage string. The argument p points to a complex128 variable in which to store the value of the flag.
func (RegistererFunc) Duration ¶
Duration defines a time.Duration flag with specified name, default value, and usage string. The return value is the address of a time.Duration variable that stores the value of the flag.
func (RegistererFunc) DurationList ¶
func (f RegistererFunc) DurationList(name string, value []time.Duration, usage string) *[]time.Duration
DurationList defines a list-style time.Duration flag with specified name, default value, and usage string. The return value is the address of a time.Duration slice that stores the values of the flag.
func (RegistererFunc) DurationListVar ¶
func (f RegistererFunc) DurationListVar(p *[]time.Duration, name string, value []time.Duration, usage string)
DurationListVar defines a list-style time.Duration flag with specified name, default value, and usage string. The argument p points to a time.Duration slice variable in which to store the value of the flag.
func (RegistererFunc) DurationSlice ¶
func (f RegistererFunc) DurationSlice(name string, value []time.Duration, sep string, usage string) *[]time.Duration
DurationSlice defines a slice-style time.Duration flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a time.Duration slice that stores the values of the flag.
func (RegistererFunc) DurationSliceVar ¶
func (f RegistererFunc) DurationSliceVar(p *[]time.Duration, name string, value []time.Duration, sep string, usage string)
DurationSliceVar defines a slice-style time.Duration flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a time.Duration slice variable in which to store the value of the flag.
func (RegistererFunc) DurationVar ¶
func (f RegistererFunc) DurationVar(p *time.Duration, name string, value time.Duration, usage string)
DurationVar defines a time.Duration flag with specified name, default value, and usage string. The argument p points to a time.Duration variable in which to store the value of the flag.
func (RegistererFunc) Float32 ¶
func (f RegistererFunc) Float32(name string, value float32, usage string) *float32
Float32 defines a float32 flag with specified name, default value, and usage string. The return value is the address of a float32 variable that stores the value of the flag.
func (RegistererFunc) Float32List ¶
func (f RegistererFunc) Float32List(name string, value []float32, usage string) *[]float32
Float32List defines a list-style float32 flag with specified name, default value, and usage string. The return value is the address of a float32 slice that stores the values of the flag.
func (RegistererFunc) Float32ListVar ¶
func (f RegistererFunc) Float32ListVar(p *[]float32, name string, value []float32, usage string)
Float32ListVar defines a list-style float32 flag with specified name, default value, and usage string. The argument p points to a float32 slice variable in which to store the value of the flag.
func (RegistererFunc) Float32Slice ¶
func (f RegistererFunc) Float32Slice(name string, value []float32, sep string, usage string) *[]float32
Float32Slice defines a slice-style float32 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a float32 slice that stores the values of the flag.
func (RegistererFunc) Float32SliceVar ¶
func (f RegistererFunc) Float32SliceVar(p *[]float32, name string, value []float32, sep string, usage string)
Float32SliceVar defines a slice-style float32 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a float32 slice variable in which to store the value of the flag.
func (RegistererFunc) Float32Var ¶
func (f RegistererFunc) Float32Var(p *float32, name string, value float32, usage string)
Float32Var defines a float32 flag with specified name, default value, and usage string. The argument p points to a float32 variable in which to store the value of the flag.
func (RegistererFunc) Float64 ¶
func (f RegistererFunc) Float64(name string, value float64, usage string) *float64
Float64 defines a float64 flag with specified name, default value, and usage string. The return value is the address of a float64 variable that stores the value of the flag.
func (RegistererFunc) Float64List ¶
func (f RegistererFunc) Float64List(name string, value []float64, usage string) *[]float64
Float64List defines a list-style float64 flag with specified name, default value, and usage string. The return value is the address of a float64 slice that stores the values of the flag.
func (RegistererFunc) Float64ListVar ¶
func (f RegistererFunc) Float64ListVar(p *[]float64, name string, value []float64, usage string)
Float64ListVar defines a list-style float64 flag with specified name, default value, and usage string. The argument p points to a float64 slice variable in which to store the value of the flag.
func (RegistererFunc) Float64Slice ¶
func (f RegistererFunc) Float64Slice(name string, value []float64, sep string, usage string) *[]float64
Float64Slice defines a slice-style float64 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a float64 slice that stores the values of the flag.
func (RegistererFunc) Float64SliceVar ¶
func (f RegistererFunc) Float64SliceVar(p *[]float64, name string, value []float64, sep string, usage string)
Float64SliceVar defines a slice-style float64 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a float64 slice variable in which to store the value of the flag.
func (RegistererFunc) Float64Var ¶
func (f RegistererFunc) Float64Var(p *float64, name string, value float64, usage string)
Float64Var defines a float64 flag with specified name, default value, and usage string. The argument p points to a float64 variable in which to store the value of the flag.
func (RegistererFunc) IPAddr ¶
IPAddr defines a netip.Addr flag with specified name, default value, and usage string. The return value is the address of a netip.Addr variable that stores the value of the flag.
func (RegistererFunc) IPAddrList ¶
IPAddrList defines a list-style netip.Addr flag with specified name, default value, and usage string. The return value is the address of a netip.Addr slice that stores the values of the flag.
func (RegistererFunc) IPAddrListVar ¶
func (f RegistererFunc) IPAddrListVar(p *[]netip.Addr, name string, value []netip.Addr, usage string)
IPAddrListVar defines a list-style netip.Addr flag with specified name, default value, and usage string. The argument p points to a netip.Addr slice variable in which to store the value of the flag.
func (RegistererFunc) IPAddrPort ¶
IPAddrPort defines a netip.AddrPort flag with specified name, default value, and usage string. The return value is the address of a netip.AddrPort variable that stores the value of the flag.
func (RegistererFunc) IPAddrPortList ¶
func (f RegistererFunc) IPAddrPortList(name string, value []netip.AddrPort, usage string) *[]netip.AddrPort
IPAddrPortList defines a list-style netip.AddrPort flag with specified name, default value, and usage string. The return value is the address of a netip.AddrPort slice that stores the values of the flag.
func (RegistererFunc) IPAddrPortListVar ¶
func (f RegistererFunc) IPAddrPortListVar(p *[]netip.AddrPort, name string, value []netip.AddrPort, usage string)
IPAddrPortListVar defines a list-style netip.AddrPort flag with specified name, default value, and usage string. The argument p points to a netip.AddrPort slice variable in which to store the value of the flag.
func (RegistererFunc) IPAddrPortSlice ¶
func (f RegistererFunc) IPAddrPortSlice(name string, value []netip.AddrPort, sep string, usage string) *[]netip.AddrPort
IPAddrPortSlice defines a slice-style netip.AddrPort flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a netip.AddrPort slice that stores the values of the flag.
func (RegistererFunc) IPAddrPortSliceVar ¶
func (f RegistererFunc) IPAddrPortSliceVar(p *[]netip.AddrPort, name string, value []netip.AddrPort, sep string, usage string)
IPAddrPortSliceVar defines a slice-style netip.AddrPort flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a netip.AddrPort slice variable in which to store the value of the flag.
func (RegistererFunc) IPAddrPortVar ¶
func (f RegistererFunc) IPAddrPortVar(p *netip.AddrPort, name string, value netip.AddrPort, usage string)
IPAddrPortVar defines a netip.AddrPort flag with specified name, default value, and usage string. The argument p points to a netip.AddrPort variable in which to store the value of the flag.
func (RegistererFunc) IPAddrSlice ¶
func (f RegistererFunc) IPAddrSlice(name string, value []netip.Addr, sep string, usage string) *[]netip.Addr
IPAddrSlice defines a slice-style netip.Addr flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a netip.Addr slice that stores the values of the flag.
func (RegistererFunc) IPAddrSliceVar ¶
func (f RegistererFunc) IPAddrSliceVar(p *[]netip.Addr, name string, value []netip.Addr, sep string, usage string)
IPAddrSliceVar defines a slice-style netip.Addr flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a netip.Addr slice variable in which to store the value of the flag.
func (RegistererFunc) IPAddrVar ¶
IPAddrVar defines a netip.Addr flag with specified name, default value, and usage string. The argument p points to a netip.Addr variable in which to store the value of the flag.
func (RegistererFunc) IPPrefix ¶
IPPrefix defines a netip.Prefix flag with specified name, default value, and usage string. The return value is the address of a netip.Prefix variable that stores the value of the flag.
func (RegistererFunc) IPPrefixList ¶
func (f RegistererFunc) IPPrefixList(name string, value []netip.Prefix, usage string) *[]netip.Prefix
IPPrefixList defines a list-style netip.Prefix flag with specified name, default value, and usage string. The return value is the address of a netip.Prefix slice that stores the values of the flag.
func (RegistererFunc) IPPrefixListVar ¶
func (f RegistererFunc) IPPrefixListVar(p *[]netip.Prefix, name string, value []netip.Prefix, usage string)
IPPrefixListVar defines a list-style netip.Prefix flag with specified name, default value, and usage string. The argument p points to a netip.Prefix slice variable in which to store the value of the flag.
func (RegistererFunc) IPPrefixSlice ¶
func (f RegistererFunc) IPPrefixSlice(name string, value []netip.Prefix, sep string, usage string) *[]netip.Prefix
IPPrefixSlice defines a slice-style netip.Prefix flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a netip.Prefix slice that stores the values of the flag.
func (RegistererFunc) IPPrefixSliceVar ¶
func (f RegistererFunc) IPPrefixSliceVar(p *[]netip.Prefix, name string, value []netip.Prefix, sep string, usage string)
IPPrefixSliceVar defines a slice-style netip.Prefix flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a netip.Prefix slice variable in which to store the value of the flag.
func (RegistererFunc) IPPrefixVar ¶
IPPrefixVar defines a netip.Prefix flag with specified name, default value, and usage string. The argument p points to a netip.Prefix variable in which to store the value of the flag.
func (RegistererFunc) Int ¶
func (f RegistererFunc) Int(name string, value int, usage string) *int
Int defines a int flag with specified name, default value, and usage string. The return value is the address of a int variable that stores the value of the flag.
func (RegistererFunc) Int8 ¶
func (f RegistererFunc) Int8(name string, value int8, usage string) *int8
Int8 defines a int8 flag with specified name, default value, and usage string. The return value is the address of a int8 variable that stores the value of the flag.
func (RegistererFunc) Int8List ¶
func (f RegistererFunc) Int8List(name string, value []int8, usage string) *[]int8
Int8List defines a list-style int8 flag with specified name, default value, and usage string. The return value is the address of a int8 slice that stores the values of the flag.
func (RegistererFunc) Int8ListVar ¶
func (f RegistererFunc) Int8ListVar(p *[]int8, name string, value []int8, usage string)
Int8ListVar defines a list-style int8 flag with specified name, default value, and usage string. The argument p points to a int8 slice variable in which to store the value of the flag.
func (RegistererFunc) Int8Slice ¶
Int8Slice defines a slice-style int8 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a int8 slice that stores the values of the flag.
func (RegistererFunc) Int8SliceVar ¶
func (f RegistererFunc) Int8SliceVar(p *[]int8, name string, value []int8, sep string, usage string)
Int8SliceVar defines a slice-style int8 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a int8 slice variable in which to store the value of the flag.
func (RegistererFunc) Int8Var ¶
func (f RegistererFunc) Int8Var(p *int8, name string, value int8, usage string)
Int8Var defines a int8 flag with specified name, default value, and usage string. The argument p points to a int8 variable in which to store the value of the flag.
func (RegistererFunc) Int16 ¶
func (f RegistererFunc) Int16(name string, value int16, usage string) *int16
Int16 defines a int16 flag with specified name, default value, and usage string. The return value is the address of a int16 variable that stores the value of the flag.
func (RegistererFunc) Int16List ¶
func (f RegistererFunc) Int16List(name string, value []int16, usage string) *[]int16
Int16List defines a list-style int16 flag with specified name, default value, and usage string. The return value is the address of a int16 slice that stores the values of the flag.
func (RegistererFunc) Int16ListVar ¶
func (f RegistererFunc) Int16ListVar(p *[]int16, name string, value []int16, usage string)
Int16ListVar defines a list-style int16 flag with specified name, default value, and usage string. The argument p points to a int16 slice variable in which to store the value of the flag.
func (RegistererFunc) Int16Slice ¶
Int16Slice defines a slice-style int16 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a int16 slice that stores the values of the flag.
func (RegistererFunc) Int16SliceVar ¶
func (f RegistererFunc) Int16SliceVar(p *[]int16, name string, value []int16, sep string, usage string)
Int16SliceVar defines a slice-style int16 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a int16 slice variable in which to store the value of the flag.
func (RegistererFunc) Int16Var ¶
func (f RegistererFunc) Int16Var(p *int16, name string, value int16, usage string)
Int16Var defines a int16 flag with specified name, default value, and usage string. The argument p points to a int16 variable in which to store the value of the flag.
func (RegistererFunc) Int32 ¶
func (f RegistererFunc) Int32(name string, value int32, usage string) *int32
Int32 defines a int32 flag with specified name, default value, and usage string. The return value is the address of a int32 variable that stores the value of the flag.
func (RegistererFunc) Int32List ¶
func (f RegistererFunc) Int32List(name string, value []int32, usage string) *[]int32
Int32List defines a list-style int32 flag with specified name, default value, and usage string. The return value is the address of a int32 slice that stores the values of the flag.
func (RegistererFunc) Int32ListVar ¶
func (f RegistererFunc) Int32ListVar(p *[]int32, name string, value []int32, usage string)
Int32ListVar defines a list-style int32 flag with specified name, default value, and usage string. The argument p points to a int32 slice variable in which to store the value of the flag.
func (RegistererFunc) Int32Slice ¶
Int32Slice defines a slice-style int32 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a int32 slice that stores the values of the flag.
func (RegistererFunc) Int32SliceVar ¶
func (f RegistererFunc) Int32SliceVar(p *[]int32, name string, value []int32, sep string, usage string)
Int32SliceVar defines a slice-style int32 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a int32 slice variable in which to store the value of the flag.
func (RegistererFunc) Int32Var ¶
func (f RegistererFunc) Int32Var(p *int32, name string, value int32, usage string)
Int32Var defines a int32 flag with specified name, default value, and usage string. The argument p points to a int32 variable in which to store the value of the flag.
func (RegistererFunc) Int64 ¶
func (f RegistererFunc) Int64(name string, value int64, usage string) *int64
Int64 defines a int64 flag with specified name, default value, and usage string. The return value is the address of a int64 variable that stores the value of the flag.
func (RegistererFunc) Int64List ¶
func (f RegistererFunc) Int64List(name string, value []int64, usage string) *[]int64
Int64List defines a list-style int64 flag with specified name, default value, and usage string. The return value is the address of a int64 slice that stores the values of the flag.
func (RegistererFunc) Int64ListVar ¶
func (f RegistererFunc) Int64ListVar(p *[]int64, name string, value []int64, usage string)
Int64ListVar defines a list-style int64 flag with specified name, default value, and usage string. The argument p points to a int64 slice variable in which to store the value of the flag.
func (RegistererFunc) Int64Slice ¶
Int64Slice defines a slice-style int64 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a int64 slice that stores the values of the flag.
func (RegistererFunc) Int64SliceVar ¶
func (f RegistererFunc) Int64SliceVar(p *[]int64, name string, value []int64, sep string, usage string)
Int64SliceVar defines a slice-style int64 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a int64 slice variable in which to store the value of the flag.
func (RegistererFunc) Int64Var ¶
func (f RegistererFunc) Int64Var(p *int64, name string, value int64, usage string)
Int64Var defines a int64 flag with specified name, default value, and usage string. The argument p points to a int64 variable in which to store the value of the flag.
func (RegistererFunc) IntList ¶
func (f RegistererFunc) IntList(name string, value []int, usage string) *[]int
IntList defines a list-style int flag with specified name, default value, and usage string. The return value is the address of a int slice that stores the values of the flag.
func (RegistererFunc) IntListVar ¶
func (f RegistererFunc) IntListVar(p *[]int, name string, value []int, usage string)
IntListVar defines a list-style int flag with specified name, default value, and usage string. The argument p points to a int slice variable in which to store the value of the flag.
func (RegistererFunc) IntSlice ¶
IntSlice defines a slice-style int flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a int slice that stores the values of the flag.
func (RegistererFunc) IntSliceVar ¶
IntSliceVar defines a slice-style int flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a int slice variable in which to store the value of the flag.
func (RegistererFunc) IntVar ¶
func (f RegistererFunc) IntVar(p *int, name string, value int, usage string)
IntVar defines a int flag with specified name, default value, and usage string. The argument p points to a int variable in which to store the value of the flag.
func (RegistererFunc) MailAddr ¶
MailAddr defines a *mail.Address flag with specified name, default value, and usage string. The return value is the address of a *mail.Address variable that stores the value of the flag.
func (RegistererFunc) MailAddrList ¶
func (f RegistererFunc) MailAddrList(name string, value []*mail.Address, usage string) *[]*mail.Address
MailAddrList defines a list-style *mail.Address flag with specified name, default value, and usage string. The return value is the address of a *mail.Address slice that stores the values of the flag.
func (RegistererFunc) MailAddrListVar ¶
func (f RegistererFunc) MailAddrListVar(p *[]*mail.Address, name string, value []*mail.Address, usage string)
MailAddrListVar defines a list-style *mail.Address flag with specified name, default value, and usage string. The argument p points to a *mail.Address slice variable in which to store the value of the flag.
func (RegistererFunc) MailAddrSlice ¶
func (f RegistererFunc) MailAddrSlice(name string, value []*mail.Address, sep string, usage string) *[]*mail.Address
MailAddrSlice defines a slice-style *mail.Address flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a *mail.Address slice that stores the values of the flag.
func (RegistererFunc) MailAddrSliceVar ¶
func (f RegistererFunc) MailAddrSliceVar(p *[]*mail.Address, name string, value []*mail.Address, sep string, usage string)
MailAddrSliceVar defines a slice-style *mail.Address flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a *mail.Address slice variable in which to store the value of the flag.
func (RegistererFunc) MailAddrVar ¶
func (f RegistererFunc) MailAddrVar(p **mail.Address, name string, value *mail.Address, usage string)
MailAddrVar defines a *mail.Address flag with specified name, default value, and usage string. The argument p points to a *mail.Address variable in which to store the value of the flag.
func (RegistererFunc) String ¶
func (f RegistererFunc) String(name string, value string, usage string) *string
String defines a string flag with specified name, default value, and usage string. The return value is the address of a string variable that stores the value of the flag.
func (RegistererFunc) StringList ¶
func (f RegistererFunc) StringList(name string, value []string, usage string) *[]string
StringList defines a list-style string flag with specified name, default value, and usage string. The return value is the address of a string slice that stores the values of the flag.
func (RegistererFunc) StringListVar ¶
func (f RegistererFunc) StringListVar(p *[]string, name string, value []string, usage string)
StringListVar defines a list-style string flag with specified name, default value, and usage string. The argument p points to a string slice variable in which to store the value of the flag.
func (RegistererFunc) StringSlice ¶
func (f RegistererFunc) StringSlice(name string, value []string, sep string, usage string) *[]string
StringSlice defines a slice-style string flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a string slice that stores the values of the flag.
func (RegistererFunc) StringSliceVar ¶
func (f RegistererFunc) StringSliceVar(p *[]string, name string, value []string, sep string, usage string)
StringSliceVar defines a slice-style string flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a string slice variable in which to store the value of the flag.
func (RegistererFunc) StringVar ¶
func (f RegistererFunc) StringVar(p *string, name string, value string, usage string)
StringVar defines a string flag with specified name, default value, and usage string. The argument p points to a string variable in which to store the value of the flag.
func (RegistererFunc) Time ¶
Time defines a time.Time flag with specified name, default value, layout format and usage string. The return value is the address of a time.Time variable that stores the value of the flag.
func (RegistererFunc) TimeList ¶
func (f RegistererFunc) TimeList(name string, value []time.Time, layout string, usage string) *[]time.Time
TimeList defines a list-style time.Time flag with specified name, default value, layout format and usage string. The return value is the address of a time.Time slice that stores the values of the flag.
func (RegistererFunc) TimeListVar ¶
func (f RegistererFunc) TimeListVar(p *[]time.Time, name string, value []time.Time, layout string, usage string)
TimeListVar defines a list-style time.Time flag with specified name, default value, layout format and usage string. The argument p points to a time.Time slice variable in which to store the value of the flag.
func (RegistererFunc) TimeSlice ¶
func (f RegistererFunc) TimeSlice(name string, value []time.Time, sep string, layout string, usage string) *[]time.Time
TimeSlice defines a slice-style time.Time flag with specified name, default value, layout format and usage string. The input strings are split around sep before parsing. The return value is the address of a time.Time slice that stores the values of the flag.
func (RegistererFunc) TimeSliceVar ¶
func (f RegistererFunc) TimeSliceVar(p *[]time.Time, name string, value []time.Time, sep string, layout string, usage string)
TimeSliceVar defines a slice-style time.Time flag with specified name, default value, layout format and usage string. The input strings are split around sep before parsing. The argument p points to a time.Time slice variable in which to store the value of the flag.
func (RegistererFunc) TimeVar ¶
func (f RegistererFunc) TimeVar(p *time.Time, name string, value time.Time, layout string, usage string)
TimeVar defines a time.Time flag with specified name, default value, layout format and usage string. The argument p points to a time.Time variable in which to store the value of the flag.
func (RegistererFunc) URL ¶
URL defines a *url.URL flag with specified name, default value, and usage string. The return value is the address of a *url.URL variable that stores the value of the flag.
func (RegistererFunc) URLList ¶
URLList defines a list-style *url.URL flag with specified name, default value, and usage string. The return value is the address of a *url.URL slice that stores the values of the flag.
func (RegistererFunc) URLListVar ¶
URLListVar defines a list-style *url.URL flag with specified name, default value, and usage string. The argument p points to a *url.URL slice variable in which to store the value of the flag.
func (RegistererFunc) URLSlice ¶
func (f RegistererFunc) URLSlice(name string, value []*url.URL, sep string, usage string) *[]*url.URL
URLSlice defines a slice-style *url.URL flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a *url.URL slice that stores the values of the flag.
func (RegistererFunc) URLSliceVar ¶
func (f RegistererFunc) URLSliceVar(p *[]*url.URL, name string, value []*url.URL, sep string, usage string)
URLSliceVar defines a slice-style *url.URL flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a *url.URL slice variable in which to store the value of the flag.
func (RegistererFunc) URLVar ¶
URLVar defines a *url.URL flag with specified name, default value, and usage string. The argument p points to a *url.URL variable in which to store the value of the flag.
func (RegistererFunc) Uint ¶
func (f RegistererFunc) Uint(name string, value uint, usage string) *uint
Uint defines a uint flag with specified name, default value, and usage string. The return value is the address of a uint variable that stores the value of the flag.
func (RegistererFunc) Uint8 ¶
func (f RegistererFunc) Uint8(name string, value uint8, usage string) *uint8
Uint8 defines a uint8 flag with specified name, default value, and usage string. The return value is the address of a uint8 variable that stores the value of the flag.
func (RegistererFunc) Uint8List ¶
func (f RegistererFunc) Uint8List(name string, value []uint8, usage string) *[]uint8
Uint8List defines a list-style uint8 flag with specified name, default value, and usage string. The return value is the address of a uint8 slice that stores the values of the flag.
func (RegistererFunc) Uint8ListVar ¶
func (f RegistererFunc) Uint8ListVar(p *[]uint8, name string, value []uint8, usage string)
Uint8ListVar defines a list-style uint8 flag with specified name, default value, and usage string. The argument p points to a uint8 slice variable in which to store the value of the flag.
func (RegistererFunc) Uint8Slice ¶
Uint8Slice defines a slice-style uint8 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a uint8 slice that stores the values of the flag.
func (RegistererFunc) Uint8SliceVar ¶
func (f RegistererFunc) Uint8SliceVar(p *[]uint8, name string, value []uint8, sep string, usage string)
Uint8SliceVar defines a slice-style uint8 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a uint8 slice variable in which to store the value of the flag.
func (RegistererFunc) Uint8Var ¶
func (f RegistererFunc) Uint8Var(p *uint8, name string, value uint8, usage string)
Uint8Var defines a uint8 flag with specified name, default value, and usage string. The argument p points to a uint8 variable in which to store the value of the flag.
func (RegistererFunc) Uint16 ¶
func (f RegistererFunc) Uint16(name string, value uint16, usage string) *uint16
Uint16 defines a uint16 flag with specified name, default value, and usage string. The return value is the address of a uint16 variable that stores the value of the flag.
func (RegistererFunc) Uint16List ¶
func (f RegistererFunc) Uint16List(name string, value []uint16, usage string) *[]uint16
Uint16List defines a list-style uint16 flag with specified name, default value, and usage string. The return value is the address of a uint16 slice that stores the values of the flag.
func (RegistererFunc) Uint16ListVar ¶
func (f RegistererFunc) Uint16ListVar(p *[]uint16, name string, value []uint16, usage string)
Uint16ListVar defines a list-style uint16 flag with specified name, default value, and usage string. The argument p points to a uint16 slice variable in which to store the value of the flag.
func (RegistererFunc) Uint16Slice ¶
func (f RegistererFunc) Uint16Slice(name string, value []uint16, sep string, usage string) *[]uint16
Uint16Slice defines a slice-style uint16 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a uint16 slice that stores the values of the flag.
func (RegistererFunc) Uint16SliceVar ¶
func (f RegistererFunc) Uint16SliceVar(p *[]uint16, name string, value []uint16, sep string, usage string)
Uint16SliceVar defines a slice-style uint16 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a uint16 slice variable in which to store the value of the flag.
func (RegistererFunc) Uint16Var ¶
func (f RegistererFunc) Uint16Var(p *uint16, name string, value uint16, usage string)
Uint16Var defines a uint16 flag with specified name, default value, and usage string. The argument p points to a uint16 variable in which to store the value of the flag.
func (RegistererFunc) Uint32 ¶
func (f RegistererFunc) Uint32(name string, value uint32, usage string) *uint32
Uint32 defines a uint32 flag with specified name, default value, and usage string. The return value is the address of a uint32 variable that stores the value of the flag.
func (RegistererFunc) Uint32List ¶
func (f RegistererFunc) Uint32List(name string, value []uint32, usage string) *[]uint32
Uint32List defines a list-style uint32 flag with specified name, default value, and usage string. The return value is the address of a uint32 slice that stores the values of the flag.
func (RegistererFunc) Uint32ListVar ¶
func (f RegistererFunc) Uint32ListVar(p *[]uint32, name string, value []uint32, usage string)
Uint32ListVar defines a list-style uint32 flag with specified name, default value, and usage string. The argument p points to a uint32 slice variable in which to store the value of the flag.
func (RegistererFunc) Uint32Slice ¶
func (f RegistererFunc) Uint32Slice(name string, value []uint32, sep string, usage string) *[]uint32
Uint32Slice defines a slice-style uint32 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a uint32 slice that stores the values of the flag.
func (RegistererFunc) Uint32SliceVar ¶
func (f RegistererFunc) Uint32SliceVar(p *[]uint32, name string, value []uint32, sep string, usage string)
Uint32SliceVar defines a slice-style uint32 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a uint32 slice variable in which to store the value of the flag.
func (RegistererFunc) Uint32Var ¶
func (f RegistererFunc) Uint32Var(p *uint32, name string, value uint32, usage string)
Uint32Var defines a uint32 flag with specified name, default value, and usage string. The argument p points to a uint32 variable in which to store the value of the flag.
func (RegistererFunc) Uint64 ¶
func (f RegistererFunc) Uint64(name string, value uint64, usage string) *uint64
Uint64 defines a uint64 flag with specified name, default value, and usage string. The return value is the address of a uint64 variable that stores the value of the flag.
func (RegistererFunc) Uint64List ¶
func (f RegistererFunc) Uint64List(name string, value []uint64, usage string) *[]uint64
Uint64List defines a list-style uint64 flag with specified name, default value, and usage string. The return value is the address of a uint64 slice that stores the values of the flag.
func (RegistererFunc) Uint64ListVar ¶
func (f RegistererFunc) Uint64ListVar(p *[]uint64, name string, value []uint64, usage string)
Uint64ListVar defines a list-style uint64 flag with specified name, default value, and usage string. The argument p points to a uint64 slice variable in which to store the value of the flag.
func (RegistererFunc) Uint64Slice ¶
func (f RegistererFunc) Uint64Slice(name string, value []uint64, sep string, usage string) *[]uint64
Uint64Slice defines a slice-style uint64 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a uint64 slice that stores the values of the flag.
func (RegistererFunc) Uint64SliceVar ¶
func (f RegistererFunc) Uint64SliceVar(p *[]uint64, name string, value []uint64, sep string, usage string)
Uint64SliceVar defines a slice-style uint64 flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a uint64 slice variable in which to store the value of the flag.
func (RegistererFunc) Uint64Var ¶
func (f RegistererFunc) Uint64Var(p *uint64, name string, value uint64, usage string)
Uint64Var defines a uint64 flag with specified name, default value, and usage string. The argument p points to a uint64 variable in which to store the value of the flag.
func (RegistererFunc) UintList ¶
func (f RegistererFunc) UintList(name string, value []uint, usage string) *[]uint
UintList defines a list-style uint flag with specified name, default value, and usage string. The return value is the address of a uint slice that stores the values of the flag.
func (RegistererFunc) UintListVar ¶
func (f RegistererFunc) UintListVar(p *[]uint, name string, value []uint, usage string)
UintListVar defines a list-style uint flag with specified name, default value, and usage string. The argument p points to a uint slice variable in which to store the value of the flag.
func (RegistererFunc) UintSlice ¶
UintSlice defines a slice-style uint flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The return value is the address of a uint slice that stores the values of the flag.
func (RegistererFunc) UintSliceVar ¶
func (f RegistererFunc) UintSliceVar(p *[]uint, name string, value []uint, sep string, usage string)
UintSliceVar defines a slice-style uint flag with specified name, default value, and usage string. The input strings are split around sep before parsing. The argument p points to a uint slice variable in which to store the value of the flag.