flag

package
v1.9.11 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2018 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitFlags

func InitFlags()

InitFlags normalizes, parses, then logs the command line flags

func WarnWordSepNormalizeFunc

func WarnWordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName

WarnWordSepNormalizeFunc changes and warns for flags that contain "_" separators

func WordSepNormalizeFunc

func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName

WordSepNormalizeFunc changes all flags that contain "_" separators

Types

type ColonSeparatedMultimapStringString added in v1.9.0

type ColonSeparatedMultimapStringString struct {
	Multimap *map[string][]string
	// contains filtered or unexported fields
}

ColonSeparatedMultimapStringString supports setting a map[string][]string from an encoding that separates keys from values with ':' and separates key-value pairs with ','. A key can be repeated multiple times, in which case the values are appended to a slice of strings associated with that key. Items in the list associated with a given key will appear in the order provided. For example: `a:hello,b:again,c:world,b:beautiful` results in `{"a": ["hello"], "b": ["again", "beautiful"], "c": ["world"]}` The first call to Set will clear the map before adding entries; subsequent calls will simply append to the map. This makes it possible to override default values with a command-line option rather than appending to defaults, while still allowing the distribution of key-value pairs across multiple flag invocations. For example: `--flag "a:hello" --flag "b:again" --flag "b:beautiful" --flag "c:world"` results in `{"a": ["hello"], "b": ["again", "beautiful"], "c": ["world"]}`

func NewColonSeparatedMultimapStringString added in v1.9.0

func NewColonSeparatedMultimapStringString(m *map[string][]string) *ColonSeparatedMultimapStringString

NewColonSeparatedMultimapStringString takes a pointer to a map[string][]string and returns the ColonSeparatedMultimapStringString flag parsing shim for that map.

func (*ColonSeparatedMultimapStringString) Empty added in v1.9.0

Empty implements OmitEmpty

func (*ColonSeparatedMultimapStringString) Set added in v1.9.0

Set implements github.com/spf13/pflag.Value

func (*ColonSeparatedMultimapStringString) String added in v1.9.0

String implements github.com/spf13/pflag.Value

func (*ColonSeparatedMultimapStringString) Type added in v1.9.0

Type implements github.com/spf13/pflag.Value

type ConfigurationMap

type ConfigurationMap map[string]string

func (*ConfigurationMap) Set

func (m *ConfigurationMap) Set(value string) error

func (*ConfigurationMap) String

func (m *ConfigurationMap) String() string

func (*ConfigurationMap) Type

func (*ConfigurationMap) Type() string

type LangleSeparatedMapStringString added in v1.9.0

type LangleSeparatedMapStringString struct {
	Map *map[string]string
	// contains filtered or unexported fields
}

LangleSeparatedMapStringString can be set from the command line with the format `--flag "string<string"`. Multiple comma-separated key-value pairs in a single invocation are supported. For example: `--flag "a<foo,b<bar"`. Multiple flag invocations are supported. For example: `--flag "a<foo" --flag "b<foo"`.

func NewLangleSeparatedMapStringString added in v1.9.0

func NewLangleSeparatedMapStringString(m *map[string]string) *LangleSeparatedMapStringString

NewLangleSeparatedMapStringString takes a pointer to a map[string]string and returns the LangleSeparatedMapStringString flag parsing shim for that map

func (*LangleSeparatedMapStringString) Empty added in v1.9.0

Empty implements OmitEmpty

func (*LangleSeparatedMapStringString) Set added in v1.9.0

Set implements github.com/spf13/pflag.Value

func (*LangleSeparatedMapStringString) String added in v1.9.0

String implements github.com/spf13/pflag.Value

func (*LangleSeparatedMapStringString) Type added in v1.9.0

Type implements github.com/spf13/pflag.Value

type MapStringBool added in v1.9.0

type MapStringBool struct {
	Map *map[string]bool
	// contains filtered or unexported fields
}

MapStringBool can be set from the command line with the format `--flag "string=bool"`. Multiple comma-separated key-value pairs in a single invocation are supported. For example: `--flag "a=true,b=false"`. Multiple flag invocations are supported. For example: `--flag "a=true" --flag "b=false"`.

func NewMapStringBool added in v1.9.0

func NewMapStringBool(m *map[string]bool) *MapStringBool

NewMapStringBool takes a pointer to a map[string]string and returns the MapStringBool flag parsing shim for that map

func (*MapStringBool) Empty added in v1.9.0

func (m *MapStringBool) Empty() bool

Empty implements OmitEmpty

func (*MapStringBool) Set added in v1.9.0

func (m *MapStringBool) Set(value string) error

Set implements github.com/spf13/pflag.Value

func (*MapStringBool) String added in v1.9.0

func (m *MapStringBool) String() string

String implements github.com/spf13/pflag.Value

func (*MapStringBool) Type added in v1.9.0

func (*MapStringBool) Type() string

Type implements github.com/spf13/pflag.Value

type MapStringString added in v1.9.0

type MapStringString struct {
	Map *map[string]string
	// contains filtered or unexported fields
}

MapStringString can be set from the command line with the format `--flag "string=string"`. Multiple comma-separated key-value pairs in a single invocation are supported. For example: `--flag "a=foo,b=bar"`. Multiple flag invocations are supported. For example: `--flag "a=foo" --flag "b=bar"`.

func NewMapStringString added in v1.9.0

func NewMapStringString(m *map[string]string) *MapStringString

NewMapStringString takes a pointer to a map[string]string and returns the MapStringString flag parsing shim for that map

func (*MapStringString) Empty added in v1.9.0

func (m *MapStringString) Empty() bool

Empty implements OmitEmpty

func (*MapStringString) Set added in v1.9.0

func (m *MapStringString) Set(value string) error

Set implements github.com/spf13/pflag.Value

func (*MapStringString) String added in v1.9.0

func (m *MapStringString) String() string

String implements github.com/spf13/pflag.Value

func (*MapStringString) Type added in v1.9.0

func (*MapStringString) Type() string

Type implements github.com/spf13/pflag.Value

type NamedCertKey

type NamedCertKey struct {
	Names             []string
	CertFile, KeyFile string
}

NamedCertKey is a flag value parsing "certfile,keyfile" and "certfile,keyfile:name,name,name".

func (*NamedCertKey) Set

func (nkc *NamedCertKey) Set(value string) error

func (*NamedCertKey) String

func (nkc *NamedCertKey) String() string

func (*NamedCertKey) Type

func (*NamedCertKey) Type() string

type NamedCertKeyArray

type NamedCertKeyArray struct {
	// contains filtered or unexported fields
}

NamedCertKeyArray is a flag value parsing NamedCertKeys, each passed with its own flag instance (in contrast to comma separated slices).

func NewNamedCertKeyArray

func NewNamedCertKeyArray(p *[]NamedCertKey) *NamedCertKeyArray

NewNamedKeyCertArray creates a new NamedCertKeyArray with the internal value pointing to p.

func (*NamedCertKeyArray) Set

func (a *NamedCertKeyArray) Set(val string) error

func (*NamedCertKeyArray) String

func (a *NamedCertKeyArray) String() string

func (*NamedCertKeyArray) Type

func (a *NamedCertKeyArray) Type() string

type OmitEmpty added in v1.9.0

type OmitEmpty interface {
	Empty() bool
}

OmitEmpty is an interface for flags to report whether their underlying value is "empty." If a flag implements OmitEmpty and returns true for a call to Empty(), it is assumed that flag may be omitted from the command line.

type StringFlag

type StringFlag struct {
	// contains filtered or unexported fields
}

StringFlag is a string flag compatible with flags and pflags that keeps track of whether it had a value supplied or not.

func NewStringFlag

func NewStringFlag(defaultVal string) StringFlag

func (*StringFlag) Default

func (f *StringFlag) Default(value string)

func (StringFlag) Provided

func (f StringFlag) Provided() bool

func (*StringFlag) Set

func (f *StringFlag) Set(value string) error

func (StringFlag) String

func (f StringFlag) String() string

func (*StringFlag) Type

func (f *StringFlag) Type() string

func (StringFlag) Value

func (f StringFlag) Value() string

type Tristate

type Tristate int

Tristate is a flag compatible with flags and pflags that keeps track of whether it had a value supplied or not.

const (
	Unset Tristate = iota // 0
	True
	False
)

func (*Tristate) Default

func (f *Tristate) Default(value bool)

func (Tristate) Provided

func (f Tristate) Provided() bool

func (*Tristate) Set

func (f *Tristate) Set(value string) error

func (Tristate) String

func (f Tristate) String() string

func (*Tristate) Type

func (f *Tristate) Type() string

func (Tristate) Value

func (f Tristate) Value() bool

Jump to

Keyboard shortcuts

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