flag

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOptionalBoolFlag

func GetOptionalBoolFlag(cmd *cobra.Command, flagName string) bool

GetOptionalBoolFlag returns the value of the specified flag from a cobra command, or the zero value (false) if the flag was not specified.

func GetOptionalStringArrayFlag

func GetOptionalStringArrayFlag(cmd *cobra.Command, flagName string) []string

GetOptionalStringArrayFlag returns the value of the specified flag from a cobra command, or the zero value if the flag was not specified.

func GetOptionalStringFlag

func GetOptionalStringFlag(cmd *cobra.Command, flagName string) string

GetOptionalStringFlag returns the value of the specified flag from a cobra command, or the zero value ("") if the flag was not specified.

Types

type Enum

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

Enum is a Cobra-compatible wrapper for defining a string flag that can be one of a specified set of values.

func NewEnum

func NewEnum(defaultValue string, allowedValues ...string) *Enum

NewEnum returns a new enum flag with the specified list of allowed values, and the specified default value if none is set.

func (*Enum) AllowedValues

func (e *Enum) AllowedValues() []string

AllowedValues returns a slice of the flag's valid values.

func (*Enum) Set

func (e *Enum) Set(s string) error

Set assigns the provided string to the enum receiver. It returns an error if the string is not an allowed value.

func (*Enum) String

func (e *Enum) String() string

String returns a string representation of the enum flag.

func (*Enum) Type

func (e *Enum) Type() string

Type returns a string representation of the Enum type.

type LabelSelector

type LabelSelector struct {
	LabelSelector *metav1.LabelSelector
}

LabelSelector is a Cobra-compatible wrapper for defining a Kubernetes label-selector flag.

func (*LabelSelector) Set

func (ls *LabelSelector) Set(s string) error

Set parses the provided string and assigns the result to the label-selector receiver. It returns an error if the string is not parseable.

func (*LabelSelector) String

func (ls *LabelSelector) String() string

String returns a string representation of the label selector flag.

func (*LabelSelector) Type

func (ls *LabelSelector) Type() string

Type returns a string representation of the LabelSelector type.

type Map

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

Map is a Cobra-compatible wrapper for defining a flag containing map data (i.e. a collection of key-value pairs).

func NewMap

func NewMap() Map

NewMap returns a Map using the default delimiters ("=" between keys and values, and "," between map entries, e.g. k1=v1,k2=v2)

func (*Map) Data

func (m *Map) Data() map[string]string

Data returns the underlying golang map storing the flag data.

func (*Map) Set

func (m *Map) Set(s string) error

Set parses the provided string according to the delimiters and assigns the result to the Map receiver. It returns an error if the string is not parseable.

func (*Map) String

func (m *Map) String() string

String returns a string representation of the Map flag.

func (*Map) Type

func (m *Map) Type() string

Type returns a string representation of the Map type.

func (Map) WithEntryDelimiter

func (m Map) WithEntryDelimiter(delimiter string) Map

WithEntryDelimiter sets the delimiter to be used between map entries.

For example, in "k1=v1&k2=v2", the entry delimiter is "&"

func (Map) WithKeyValueDelimiter

func (m Map) WithKeyValueDelimiter(delimiter string) Map

WithKeyValueDelimiter sets the delimiter to be used between keys and values.

For example, in "k1=v1&k2=v2", the key-value delimiter is "="

type OptionalBool

type OptionalBool struct {
	Value *bool
}

func NewOptionalBool

func NewOptionalBool(defaultValue *bool) OptionalBool

func (*OptionalBool) Set

func (f *OptionalBool) Set(val string) error

func (*OptionalBool) String

func (f *OptionalBool) String() string

String returns a string representation of the enum flag.

func (*OptionalBool) Type

func (f *OptionalBool) Type() string

type StringArray

type StringArray []string

StringArray is a Cobra-compatible named type for defining a string slice flag.

func NewStringArray

func NewStringArray(initial ...string) StringArray

NewStringArray returns a StringArray for a provided slice of values.

func (*StringArray) Set

func (sa *StringArray) Set(s string) error

Set comma-splits the provided string and assigns the results to the receiver. It returns an error if the string is not parseable.

func (*StringArray) String

func (sa *StringArray) String() string

String returns a comma-separated list of the items in the string array.

func (*StringArray) Type

func (sa *StringArray) Type() string

Type returns a string representation of the StringArray type.

Jump to

Keyboard shortcuts

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