flagvar: github.com/sgreben/flagvar Index | Examples | Files

package flagvar

import "github.com/sgreben/flagvar"

Package flagvar provides flag argument types for the standard `flag` package. All types implement `flag.Value`, and can be passed to `flag.Var()`.

Code:

var (
    fruit    = flagvar.Enum{Choices: []string{"apple", "banana"}}
    urls     flagvar.URLs
    settings flagvar.AssignmentsMap
)

fs := flag.FlagSet{}
fs.Var(&fruit, "fruit", "a fruit")
fs.Var(&urls, "url", "a URL")
fs.Var(&settings, "set", "set key=value")
fs.Parse([]string{
    "-fruit", "apple",
    "-url", "https://github.com/sgreben/flagvar",
    "-set", "hello=world",
})

fmt.Println("fruit:", fruit.Value)
fmt.Println("urls:", urls.Values)
for key, value := range settings.Values {
    fmt.Printf("settings: '%s' is set to '%s'\n", key, value)
}

Output:

fruit: apple
urls: [https://github.com/sgreben/flagvar]
settings: 'hello' is set to 'world'

Index

Examples

Package Files

alternative.go assignment.go cidr.go enum.go file.go floats.go glob.go ints.go ip.go json.go package_doc.go regexp.go string.go tcp_addr.go template.go time.go time_format.go udp_addr.go unix_addr.go url.go wrap.go

type Alternative Uses

type Alternative struct {
    Either   flag.Value
    Or       flag.Value
    EitherOk bool
}

Alternative tries to parse the argument using `Either`, and if that fails, using `Or`. `EitherOk` is true if the first attempt succeed.

func (*Alternative) Help Uses

func (fv *Alternative) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Alternative) Set Uses

func (fv *Alternative) Set(v string) error

Set is flag.Value.Set

func (*Alternative) String Uses

func (fv *Alternative) String() string

type Assignment Uses

type Assignment struct {
    Separator string

    Value struct {
        Key   string
        Value string
    }
    Text string
}

Assignment is a `flag.Value` for `KEY=VALUE` arguments. The value of the `Separator` field is used instead of `"="` when set.

func (*Assignment) Help Uses

func (fv *Assignment) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Assignment) Set Uses

func (fv *Assignment) Set(v string) error

Set is flag.Value.Set

func (*Assignment) String Uses

func (fv *Assignment) String() string

type Assignments Uses

type Assignments struct {
    Separator string

    Values []struct {
        Key   string
        Value string
    }
    Texts []string
}

Assignments is a `flag.Value` for `KEY=VALUE` arguments. The value of the `Separator` field is used instead of `"="` when set.

func (*Assignments) Help Uses

func (fv *Assignments) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Assignments) Set Uses

func (fv *Assignments) Set(v string) error

Set is flag.Value.Set

func (*Assignments) String Uses

func (fv *Assignments) String() string

type AssignmentsMap Uses

type AssignmentsMap struct {
    Separator string

    Values map[string]string
    Texts  []string
}

AssignmentsMap is a `flag.Value` for `KEY=VALUE` arguments. The value of the `Separator` field is used instead of `"="` when set.

func (*AssignmentsMap) Help Uses

func (fv *AssignmentsMap) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*AssignmentsMap) Set Uses

func (fv *AssignmentsMap) Set(v string) error

Set is flag.Value.Set

func (*AssignmentsMap) String Uses

func (fv *AssignmentsMap) String() string

type CIDR Uses

type CIDR struct {
    Value struct {
        IPNet *net.IPNet
        IP    net.IP
    }
    Text string
}

CIDR is a `flag.Value` for CIDR notation IP address and prefix length arguments.

func (*CIDR) Help Uses

func (fv *CIDR) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*CIDR) Set Uses

func (fv *CIDR) Set(v string) error

Set is flag.Value.Set

func (*CIDR) String Uses

func (fv *CIDR) String() string

type CIDRs Uses

type CIDRs struct {
    Values []struct {
        IPNet *net.IPNet
        IP    net.IP
    }
    Texts []string
}

CIDRs is a `flag.Value` for CIDR notation IP address and prefix length arguments.

func (*CIDRs) Help Uses

func (fv *CIDRs) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*CIDRs) Set Uses

func (fv *CIDRs) Set(v string) error

Set is flag.Value.Set

func (*CIDRs) String Uses

func (fv *CIDRs) String() string

type CIDRsCSV Uses

type CIDRsCSV struct {
    Separator  string
    Accumulate bool

    Values []struct {
        IPNet *net.IPNet
        IP    net.IP
    }
    Texts []string
}

CIDRsCSV is a `flag.Value` for CIDR notation IP address and prefix length arguments. If `Accumulate` is set, the values of all instances of the flag are accumulated. The `Separator` field is used instead of the comma when set.

func (*CIDRsCSV) Help Uses

func (fv *CIDRsCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*CIDRsCSV) Set Uses

func (fv *CIDRsCSV) Set(v string) error

Set is flag.Value.Set

func (*CIDRsCSV) String Uses

func (fv *CIDRsCSV) String() string

type Enum Uses

type Enum struct {
    Choices       []string
    CaseSensitive bool

    Value string
    Text  string
}

Enum is a `flag.Value` for one-of-a-fixed-set string arguments. The value of the `Choices` field defines the valid choices. If `CaseSensitive` is set to `true` (default `false`), the comparison is case-sensitive.

Code:

mode := flagvar.Enum{Choices: []string{"fast", "exact"}}
fruit := flagvar.Enums{Choices: []string{"apple", "pear"}}
letters := flagvar.EnumsCSV{
    Choices:       []string{"a", "A", "b", "B"},
    CaseSensitive: true,
}
levels := flagvar.EnumSetCSV{
    Choices:    []string{"debug", "info", "warn", "error"},
    Accumulate: true,
}

var fs flag.FlagSet
fs.Var(&mode, "mode", "set a mode")
fs.Var(&fruit, "fruit", "add a fruit")
fs.Var(&letters, "letters", "select some letters")
fs.Var(&levels, "levels", "enable log levels")

fs.Parse([]string{
    "-fruit", "Apple",
    "-fruit", "apple",
    "-fruit", "PEAR",
    "-letters", "b,A,a",
    "-levels", "debug",
    "-levels", "debug,info,error",
    "-mode", "fast",
    "-mode", "exact",
})

fmt.Println("fruit:", fruit.Values)
fmt.Println("letters:", letters.Values)
fmt.Println("levels:", levels.Values())
fmt.Println("mode:", mode.Value)

Output:

fruit: [apple apple pear]
letters: [b A a]
levels: [debug error info]
mode: exact

func (*Enum) Help Uses

func (fv *Enum) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Enum) Set Uses

func (fv *Enum) Set(v string) error

Set is flag.Value.Set

func (*Enum) String Uses

func (fv *Enum) String() string

type EnumSet Uses

type EnumSet struct {
    Choices       []string
    CaseSensitive bool

    Value map[string]bool
    Texts []string
}

EnumSet is a `flag.Value` for one-of-a-fixed-set string arguments. Only distinct values are returned. The value of the `Choices` field defines the valid choices. If `CaseSensitive` is set to `true` (default `false`), the comparison is case-sensitive.

func (*EnumSet) Help Uses

func (fv *EnumSet) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*EnumSet) Set Uses

func (fv *EnumSet) Set(v string) error

Set is flag.Value.Set

func (*EnumSet) String Uses

func (fv *EnumSet) String() string

func (*EnumSet) Values Uses

func (fv *EnumSet) Values() (out []string)

Values returns a string slice of specified values.

type EnumSetCSV Uses

type EnumSetCSV struct {
    Choices       []string
    Separator     string
    Accumulate    bool
    CaseSensitive bool

    Value map[string]bool
    Texts []string
}

EnumSetCSV is a `flag.Value` for comma-separated enum arguments. Only distinct values are returned. The value of the `Choices` field defines the valid choices. If `Accumulate` is set, the values of all instances of the flag are accumulated. The `Separator` field is used instead of the comma when set. If `CaseSensitive` is set to `true` (default `false`), the comparison is case-sensitive.

func (*EnumSetCSV) Help Uses

func (fv *EnumSetCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*EnumSetCSV) Set Uses

func (fv *EnumSetCSV) Set(v string) error

Set is flag.Value.Set

func (*EnumSetCSV) String Uses

func (fv *EnumSetCSV) String() string

func (*EnumSetCSV) Values Uses

func (fv *EnumSetCSV) Values() (out []string)

Values returns a string slice of specified values.

type Enums Uses

type Enums struct {
    Choices       []string
    CaseSensitive bool

    Values []string
    Texts  []string
}

Enums is a `flag.Value` for one-of-a-fixed-set string arguments. The value of the `Choices` field defines the valid choices. If `CaseSensitive` is set to `true` (default `false`), the comparison is case-sensitive.

func (*Enums) Help Uses

func (fv *Enums) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Enums) Set Uses

func (fv *Enums) Set(v string) error

Set is flag.Value.Set

func (*Enums) String Uses

func (fv *Enums) String() string

type EnumsCSV Uses

type EnumsCSV struct {
    Choices       []string
    Separator     string
    Accumulate    bool
    CaseSensitive bool

    Values []string
    Texts  []string
}

EnumsCSV is a `flag.Value` for comma-separated enum arguments. The value of the `Choices` field defines the valid choices. If `Accumulate` is set, the values of all instances of the flag are accumulated. The `Separator` field is used instead of the comma when set. If `CaseSensitive` is set to `true` (default `false`), the comparison is case-sensitive.

func (*EnumsCSV) Help Uses

func (fv *EnumsCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*EnumsCSV) Set Uses

func (fv *EnumsCSV) Set(v string) error

Set is flag.Value.Set

func (*EnumsCSV) String Uses

func (fv *EnumsCSV) String() string

type File Uses

type File struct {
    Validate func(os.FileInfo, error) error

    Value string
}

File is a `flag.Value` for file path arguments. By default, any errors from os.Stat are returned. Alternatively, the value of the `Validate` field is used as a validator when specified.

func (*File) Set Uses

func (fv *File) Set(v string) error

Set is flag.Value.Set

func (*File) String Uses

func (fv *File) String() string

type Files Uses

type Files struct {
    Validate func(os.FileInfo, error) error

    Values []string
}

Files is a `flag.Value` for file path arguments. By default, any errors from os.Stat are returned. Alternatively, the value of the `Validate` field is used as a validator when specified.

func (*Files) Set Uses

func (fv *Files) Set(v string) error

Set is flag.Value.Set

func (*Files) String Uses

func (fv *Files) String() string

type Float Uses

type Float struct {
    BitSize int

    Value float64
    Text  string
}

Float is a `flag.Value` for a float argument. The `BitSize` field is used for parsing when set.

func (*Float) Help Uses

func (fv *Float) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Float) Set Uses

func (fv *Float) Set(v string) error

Set is flag.Value.Set

func (*Float) String Uses

func (fv *Float) String() string

type Floats Uses

type Floats struct {
    BitSize int

    Values []float64
    Texts  []string
}

Floats is a `flag.Value` for float arguments. The `BitSize` field is used for parsing when set.

func (*Floats) Help Uses

func (fv *Floats) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Floats) Set Uses

func (fv *Floats) Set(v string) error

Set is flag.Value.Set

func (*Floats) String Uses

func (fv *Floats) String() string

type FloatsCSV Uses

type FloatsCSV struct {
    BitSize    int
    Separator  string
    Accumulate bool

    Values []float64
    Texts  []string
}

FloatsCSV is a `flag.Value` for comma-separated `float` arguments. If `Accumulate` is set, the values of all instances of the flag are accumulated. The `BitSize` fields are used for parsing when set. The `Separator` field is used instead of the comma when set.

func (*FloatsCSV) Help Uses

func (fv *FloatsCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*FloatsCSV) Set Uses

func (fv *FloatsCSV) Set(v string) error

Set is flag.Value.Set

func (*FloatsCSV) String Uses

func (fv *FloatsCSV) String() string

type Glob Uses

type Glob struct {
    Separators *[]rune

    Value glob.Glob
    Text  string
}

Glob is a `flag.Value` for glob syntax arguments. By default, `filepath.Separator` is used as a separator. If `Separators` is non-nil, its elements are used as separators. To have no separators, set `Separators` to a (non-nil) pointer to an empty slice.

func (*Glob) Help Uses

func (fv *Glob) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Glob) Set Uses

func (fv *Glob) Set(v string) error

Set is flag.Value.Set

func (*Glob) String Uses

func (fv *Glob) String() string

type Globs Uses

type Globs struct {
    Separators *[]rune

    Values []glob.Glob
    Texts  []string
}

Globs is a `flag.Value` for glob syntax arguments. By default, `filepath.Separator` is used as a separator. If `Separators` is non-nil, its elements are used as separators. To have no separators, set `Separators` to a (non-nil) pointer to an empty slice.

func (*Globs) Help Uses

func (fv *Globs) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Globs) Set Uses

func (fv *Globs) Set(v string) error

Set is flag.Value.Set

func (*Globs) String Uses

func (fv *Globs) String() string

type IP Uses

type IP struct {
    Value net.IP
    Text  string
}

IP is a `flag.Value` for IP addresses.

func (*IP) Help Uses

func (fv *IP) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*IP) Set Uses

func (fv *IP) Set(v string) error

Set is flag.Value.Set

func (*IP) String Uses

func (fv *IP) String() string

type IPs Uses

type IPs struct {
    Values []net.IP
    Texts  []string
}

IPs is a `flag.Value` for IP addresses.

func (*IPs) Help Uses

func (fv *IPs) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*IPs) Set Uses

func (fv *IPs) Set(v string) error

Set is flag.Value.Set

func (*IPs) String Uses

func (fv *IPs) String() string

type IPsCSV Uses

type IPsCSV struct {
    Separator  string
    Accumulate bool

    Values []net.IP
    Texts  []string
}

IPsCSV is a `flag.Value` for IP addresses. If `Accumulate` is set, the values of all instances of the flag are accumulated. The `Separator` field is used instead of the comma when set.

func (*IPsCSV) Help Uses

func (fv *IPsCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*IPsCSV) Set Uses

func (fv *IPsCSV) Set(v string) error

Set is flag.Value.Set

func (*IPsCSV) String Uses

func (fv *IPsCSV) String() string

type Ints Uses

type Ints struct {
    Base    int
    BitSize int

    Values []int64
    Texts  []string
}

Ints is a `flag.Value` for `int` arguments. The `Base` and `BitSize` fields are used for parsing when set.

func (*Ints) Help Uses

func (fv *Ints) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Ints) Set Uses

func (fv *Ints) Set(v string) error

Set is flag.Value.Set

func (*Ints) String Uses

func (fv *Ints) String() string

type IntsCSV Uses

type IntsCSV struct {
    Base       int
    BitSize    int
    Separator  string
    Accumulate bool

    Values []int64
    Texts  []string
}

IntsCSV is a `flag.Value` for comma-separated `int` arguments. If `Accumulate` is set, the values of all instances of the flag are accumulated. The `Base` and `BitSize` fields are used for parsing when set. The `Separator` field is used instead of the comma when set.

func (*IntsCSV) Help Uses

func (fv *IntsCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*IntsCSV) Set Uses

func (fv *IntsCSV) Set(v string) error

Set is flag.Value.Set

func (*IntsCSV) String Uses

func (fv *IntsCSV) String() string

type JSON Uses

type JSON struct {
    Value interface{}
    Text  string
}

JSON is a `flag.Value` for JSON arguments.

func (*JSON) Help Uses

func (fv *JSON) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*JSON) Set Uses

func (fv *JSON) Set(v string) error

Set is flag.Value.Set

func (*JSON) String Uses

func (fv *JSON) String() string

type JSONs Uses

type JSONs struct {
    Value  func() interface{}
    Values []interface{}
    Texts  []string
}

JSONs is a `flag.Value` for JSON arguments. If non-nil, the `Value` field is used to generate template values.

func (*JSONs) Help Uses

func (fv *JSONs) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*JSONs) Set Uses

func (fv *JSONs) Set(v string) (err error)

Set is flag.Value.Set

func (*JSONs) String Uses

func (fv *JSONs) String() string

type Regexp Uses

type Regexp struct {
    POSIX bool

    Value *regexp.Regexp
    Text  string
}

Regexp is a `flag.Value` for regular expression arguments. If `POSIX` is set to true, `regexp.CompilePOSIX` is used instead of `regexp.Compile`.

func (*Regexp) Help Uses

func (fv *Regexp) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Regexp) Set Uses

func (fv *Regexp) Set(v string) error

Set is flag.Value.Set

func (*Regexp) String Uses

func (fv *Regexp) String() string

type Regexps Uses

type Regexps struct {
    POSIX bool

    Values []*regexp.Regexp
    Texts  []string
}

Regexps is a `flag.Value` for regular expression arguments.

func (*Regexps) Help Uses

func (fv *Regexps) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Regexps) Set Uses

func (fv *Regexps) Set(v string) error

Set is flag.Value.Set

func (*Regexps) String Uses

func (fv *Regexps) String() string

type StringSet Uses

type StringSet struct {
    Value map[string]bool
}

StringSet is a `flag.Value` for `string` arguments. Only distinct values are returned.

func (*StringSet) Set Uses

func (fv *StringSet) Set(v string) error

Set is flag.Value.Set

func (*StringSet) String Uses

func (fv *StringSet) String() string

func (*StringSet) Values Uses

func (fv *StringSet) Values() (out []string)

Values returns a string slice of specified values.

type StringSetCSV Uses

type StringSetCSV struct {
    Separator  string
    Accumulate bool

    Value  map[string]bool
    Values []string
}

StringSetCSV is a `flag.Value` for comma-separated string arguments. If `Accumulate` is set, the values of all instances of the flag are accumulated. The `Separator` field is used instead of the comma when set. If `CaseSensitive` is set to `true` (default `false`), the comparison is case-sensitive.

func (*StringSetCSV) Help Uses

func (fv *StringSetCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*StringSetCSV) Set Uses

func (fv *StringSetCSV) Set(v string) error

Set is flag.Value.Set

func (*StringSetCSV) String Uses

func (fv *StringSetCSV) String() string

type Strings Uses

type Strings struct {
    Values []string
}

Strings is a `flag.Value` for `string` arguments.

func (*Strings) Set Uses

func (fv *Strings) Set(v string) error

Set is flag.Value.Set

func (*Strings) String Uses

func (fv *Strings) String() string

type TCPAddr Uses

type TCPAddr struct {
    Network string

    Value *net.TCPAddr
    Text  string
}

TCPAddr is a `flag.Value` for TCP addresses. The `Network` field is used if set, otherwise "tcp".

func (*TCPAddr) Help Uses

func (fv *TCPAddr) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*TCPAddr) Set Uses

func (fv *TCPAddr) Set(v string) error

Set is flag.Value.Set

func (*TCPAddr) String Uses

func (fv *TCPAddr) String() string

type TCPAddrs Uses

type TCPAddrs struct {
    Network string

    Values []*net.TCPAddr
    Texts  []string
}

TCPAddrs is a `flag.Value` for TCPAddr addresses. The `Network` field is used if set, otherwise "tcp".

func (*TCPAddrs) Help Uses

func (fv *TCPAddrs) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*TCPAddrs) Set Uses

func (fv *TCPAddrs) Set(v string) error

Set is flag.Value.Set

func (*TCPAddrs) String Uses

func (fv *TCPAddrs) String() string

type TCPAddrsCSV Uses

type TCPAddrsCSV struct {
    Network    string
    Separator  string
    Accumulate bool

    Values []*net.TCPAddr
    Texts  []string
}

TCPAddrsCSV is a `flag.Value` for TCPAddr addresses. The `Network` field is used if set, otherwise "tcp". If `Accumulate` is set, the values of all instances of the flag are accumulated. The `Separator` field is used instead of the comma when set.

func (*TCPAddrsCSV) Help Uses

func (fv *TCPAddrsCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*TCPAddrsCSV) Set Uses

func (fv *TCPAddrsCSV) Set(v string) error

Set is flag.Value.Set

func (*TCPAddrsCSV) String Uses

func (fv *TCPAddrsCSV) String() string

type Template Uses

type Template struct {
    Root *template.Template

    Value *template.Template
    Text  string
}

Template is a `flag.Value` for `text.Template` arguments. The value of the `Root` field is used as a root template when specified.

Code:

fv := flagvar.Template{
    Root: template.New("example").Funcs(template.FuncMap{
        "toUpper": func(s string) string {
            return strings.ToUpper(s)
        },
    }),
}
var fs flag.FlagSet
fs.Var(&fv, "template", "")

fs.Parse([]string{"-template", `{{ toUpper "hello, world!" }}`})
fv.Value.Execute(os.Stdout, nil)

Output:

HELLO, WORLD!

func (*Template) Help Uses

func (fv *Template) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Template) Set Uses

func (fv *Template) Set(v string) error

Set is flag.Value.Set

func (*Template) String Uses

func (fv *Template) String() string

type TemplateFile Uses

type TemplateFile struct {
    Root *template.Template

    Value *template.Template
    Text  string
}

Template is a `flag.Value` for `text.Template` arguments. The value of the `Root` field is used as a root template when specified. The value specified on the command line is the path to the template

func (*TemplateFile) Help Uses

func (fv *TemplateFile) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*TemplateFile) Set Uses

func (fv *TemplateFile) Set(v string) error

Set is flag.Value.Set

func (*TemplateFile) String Uses

func (fv *TemplateFile) String() string

type Templates Uses

type Templates struct {
    Root *template.Template

    Values []*template.Template
    Texts  []string
}

Templates is a `flag.Value` for `text.Template` arguments. The value of the `Root` field is used as a root template when specified.

func (*Templates) Help Uses

func (fv *Templates) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Templates) Set Uses

func (fv *Templates) Set(v string) error

Set is flag.Value.Set

func (*Templates) String Uses

func (fv *Templates) String() string

type Time Uses

type Time struct {
    Layout string

    Value time.Time
    Text  string
}

Time is a `flag.Value` for `time.Time` arguments. The value of the `Layout` field is used for parsing when specified. Otherwise, `time.RFC3339` is used.

func (*Time) Help Uses

func (fv *Time) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Time) Set Uses

func (fv *Time) Set(v string) error

Set is flag.Value.Set

func (*Time) String Uses

func (fv *Time) String() string

type TimeFormat Uses

type TimeFormat struct {
    Value string
    Text  string
}

TimeFormat is a `flag.Value` for `time.Time` formats.

func (*TimeFormat) Help Uses

func (fv *TimeFormat) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*TimeFormat) Set Uses

func (fv *TimeFormat) Set(v string) error

Set is flag.Value.Set

func (*TimeFormat) String Uses

func (fv *TimeFormat) String() string

type Times Uses

type Times struct {
    Layout string

    Values []time.Time
    Texts  []string
}

Times is a `flag.Value` for `time.Time` arguments. The value of the `Layout` field is used for parsing when specified. Otherwise, `time.RFC3339` is used.

func (*Times) Help Uses

func (fv *Times) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Times) Set Uses

func (fv *Times) Set(v string) error

Set is flag.Value.Set

func (*Times) String Uses

func (fv *Times) String() string

type UDPAddr Uses

type UDPAddr struct {
    Network string

    Value *net.UDPAddr
    Text  string
}

UDPAddr is a `flag.Value` for UDP addresses. The `Network` field is used if set, otherwise "udp".

func (*UDPAddr) Help Uses

func (fv *UDPAddr) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*UDPAddr) Set Uses

func (fv *UDPAddr) Set(v string) error

Set is flag.Value.Set

func (*UDPAddr) String Uses

func (fv *UDPAddr) String() string

type UDPAddrs Uses

type UDPAddrs struct {
    Network string

    Values []*net.UDPAddr
    Texts  []string
}

UDPAddrs is a `flag.Value` for UDPAddr addresses. The `Network` field is used if set, otherwise "udp".

func (*UDPAddrs) Help Uses

func (fv *UDPAddrs) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*UDPAddrs) Set Uses

func (fv *UDPAddrs) Set(v string) error

Set is flag.Value.Set

func (*UDPAddrs) String Uses

func (fv *UDPAddrs) String() string

type UDPAddrsCSV Uses

type UDPAddrsCSV struct {
    Network    string
    Separator  string
    Accumulate bool

    Values []*net.UDPAddr
    Texts  []string
}

UDPAddrsCSV is a `flag.Value` for UDPAddr addresses. The `Network` field is used if set, otherwise "udp". If `Accumulate` is set, the values of all instances of the flag are accumulated. The `Separator` field is used instead of the comma when set.

func (*UDPAddrsCSV) Help Uses

func (fv *UDPAddrsCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*UDPAddrsCSV) Set Uses

func (fv *UDPAddrsCSV) Set(v string) error

Set is flag.Value.Set

func (*UDPAddrsCSV) String Uses

func (fv *UDPAddrsCSV) String() string

type URL Uses

type URL struct {
    Value *url.URL
    Text  string
}

URL is a `flag.Value` for `url.URL` arguments.

func (*URL) Help Uses

func (fv *URL) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*URL) Set Uses

func (fv *URL) Set(v string) error

Set is flag.Value.Set

func (*URL) String Uses

func (fv *URL) String() string

type URLs Uses

type URLs struct {
    Values []*url.URL
    Texts  []string
}

URLs is a `flag.Value` for `url.URL` arguments.

func (*URLs) Help Uses

func (fv *URLs) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*URLs) Set Uses

func (fv *URLs) Set(v string) error

Set is flag.Value.Set

func (*URLs) String Uses

func (fv *URLs) String() string

type UnixAddr Uses

type UnixAddr struct {
    Network string

    Value *net.UnixAddr
    Text  string
}

UnixAddr is a `flag.Value` for Unix addresses. The `Network` field is used if set, otherwise "unix".

func (*UnixAddr) Help Uses

func (fv *UnixAddr) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*UnixAddr) Set Uses

func (fv *UnixAddr) Set(v string) error

Set is flag.Value.Set

func (*UnixAddr) String Uses

func (fv *UnixAddr) String() string

type UnixAddrs Uses

type UnixAddrs struct {
    Network string

    Values []*net.UnixAddr
    Texts  []string
}

UnixAddrs is a `flag.Value` for UnixAddr addresses. The `Network` field is used if set, otherwise "unix".

func (*UnixAddrs) Help Uses

func (fv *UnixAddrs) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*UnixAddrs) Set Uses

func (fv *UnixAddrs) Set(v string) error

Set is flag.Value.Set

func (*UnixAddrs) String Uses

func (fv *UnixAddrs) String() string

type UnixAddrsCSV Uses

type UnixAddrsCSV struct {
    Network    string
    Separator  string
    Accumulate bool

    Values []*net.UnixAddr
    Texts  []string
}

UnixAddrsCSV is a `flag.Value` for UnixAddr addresses. The `Network` field is used if set, otherwise "unix". If `Accumulate` is set, the values of all instances of the flag are accumulated. The `Separator` field is used instead of the comma when set.

func (*UnixAddrsCSV) Help Uses

func (fv *UnixAddrsCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*UnixAddrsCSV) Set Uses

func (fv *UnixAddrsCSV) Set(v string) error

Set is flag.Value.Set

func (*UnixAddrsCSV) String Uses

func (fv *UnixAddrsCSV) String() string

type Wrap Uses

type Wrap struct {
    Value   flag.Value
    Updated func()
}

Wrap wraps a `flag.Value` and calls `Updated` each time the underlying value is set.

func (*Wrap) Help Uses

func (fv *Wrap) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*Wrap) Set Uses

func (fv *Wrap) Set(v string) error

Set is flag.Value.Set

func (*Wrap) String Uses

func (fv *Wrap) String() string

type WrapCSV Uses

type WrapCSV struct {
    Value      flag.Value
    Separator  string
    UpdatedOne func()
    UpdatedAll func()
    StringFunc func() string
}

WrapCSV wraps a `flag.Value` and calls `UpdatedOne` after each single value and `UpdatedAll` after each CSV batch. The `Separator` field is used instead of the comma when set.

func (*WrapCSV) Help Uses

func (fv *WrapCSV) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*WrapCSV) Set Uses

func (fv *WrapCSV) Set(v string) error

Set is flag.Value.Set

func (*WrapCSV) String Uses

func (fv *WrapCSV) String() string

type WrapFunc Uses

type WrapFunc func() flag.Value

WrapFunc wraps a nullary function returning a `flag.Value` This can be used to switch between different argument parsers.

func (WrapFunc) Help Uses

func (fv WrapFunc) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (WrapFunc) Set Uses

func (fv WrapFunc) Set(v string) error

Set is flag.Value.Set

func (WrapFunc) String Uses

func (fv WrapFunc) String() string

type WrapPointer Uses

type WrapPointer struct {
    Value *flag.Value
}

WrapPointer wraps a pointer to a `flag.Value` This can be used to switch between different argument parsers.

func (*WrapPointer) Help Uses

func (fv *WrapPointer) Help() string

Help returns a string suitable for inclusion in a flag help message.

func (*WrapPointer) Set Uses

func (fv *WrapPointer) Set(v string) error

Set is flag.Value.Set

func (WrapPointer) String Uses

func (fv WrapPointer) String() string

Package flagvar imports 15 packages (graph). Updated 2020-07-11. Refresh now. Tools for package owners.