flagext

package
v0.0.0-...-c41c587 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 411

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeprecatedFlagsUsed = promauto.NewCounter(
	prometheus.CounterOpts{
		Name: "deprecated_flags_inuse_total",
		Help: "The number of deprecated flags currently set.",
	})

DeprecatedFlagsUsed is the metric that counts deprecated flags set.

Functions

func DefaultValues

func DefaultValues(rs ...interface{})

DefaultValues initiates a set of configs (Registerers) with their defaults.

func DeprecatedFlag

func DeprecatedFlag(f *flag.FlagSet, name, message string, logger log.Logger)

DeprecatedFlag logs a warning when you try to use it.

func IgnoredFlag

func IgnoredFlag(f *flag.FlagSet, name, message string)

IgnoredFlag ignores set value, without any warning

func ParseFlagsAndArguments

func ParseFlagsAndArguments(f *flag.FlagSet) ([]string, error)

ParseFlagsAndArguments calls Parse() on the input flag.FlagSet and returns the parsed arguments.

func ParseFlagsWithoutArguments

func ParseFlagsWithoutArguments(f *flag.FlagSet) error

ParseFlagsWithoutArguments calls Parse() on the input flag.FlagSet and enforces no arguments have been parsed. This utility should be called whenever we only expect CLI flags but no arguments.

func RegisterFlags

func RegisterFlags(rs ...Registerer)

RegisterFlags registers flags with the provided Registerers

func RegisterFlagsWithLogger

func RegisterFlagsWithLogger(logger log.Logger, rs ...interface{})

RegisterFlagsWithLogger registers flags with the provided Registerers

Types

type Bytes

type Bytes uint64

Bytes is a data type which supports use as a flag and yaml serialization/deserialization with units.

func (Bytes) MarshalYAML

func (b Bytes) MarshalYAML() (interface{}, error)

func (*Bytes) Set

func (b *Bytes) Set(s string) error

Set implements flag.Value

func (*Bytes) String

func (b *Bytes) String() string

String implements flag.Value

func (*Bytes) UnmarshalYAML

func (b *Bytes) UnmarshalYAML(unmarshal func(interface{}) error) error

type CIDR

type CIDR struct {
	Value *net.IPNet
}

CIDR is a network CIDR.

func (*CIDR) Set

func (c *CIDR) Set(s string) error

Set implements flag.Value.

func (CIDR) String

func (c CIDR) String() string

String implements flag.Value.

type CIDRSliceCSV

type CIDRSliceCSV []CIDR

CIDRSliceCSV is a slice of CIDRs that is parsed from a comma-separated string. It implements flag.Value and yaml Marshalers.

func (CIDRSliceCSV) MarshalYAML

func (c CIDRSliceCSV) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*CIDRSliceCSV) Set

func (c *CIDRSliceCSV) Set(s string) error

Set implements flag.Value

func (CIDRSliceCSV) String

func (c CIDRSliceCSV) String() string

String implements flag.Value

func (*CIDRSliceCSV) UnmarshalYAML

func (c *CIDRSliceCSV) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

type DayValue

type DayValue struct {
	model.Time
	// contains filtered or unexported fields
}

DayValue is a model.Time that can be used as a flag. NB it only parses days!

func NewDayValue

func NewDayValue(t model.Time) DayValue

NewDayValue makes a new DayValue; will round t down to the nearest midnight.

func (*DayValue) IsSet

func (v *DayValue) IsSet() bool

IsSet returns true is the DayValue has been set.

func (DayValue) MarshalYAML

func (v DayValue) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*DayValue) Set

func (v *DayValue) Set(s string) error

Set implements flag.Value

func (DayValue) String

func (v DayValue) String() string

String implements flag.Value

func (*DayValue) UnmarshalYAML

func (v *DayValue) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

type Registerer

type Registerer interface {
	RegisterFlags(*flag.FlagSet)
}

Registerer is a thing that can RegisterFlags

type RegistererWithLogger

type RegistererWithLogger interface {
	RegisterFlags(*flag.FlagSet, log.Logger)
}

RegistererWithLogger is a thing that can RegisterFlags with a Logger

type Secret

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

func SecretWithValue

func SecretWithValue(v string) Secret

SecretWithValue returns Secret with specified value.

func (Secret) MarshalYAML

func (v Secret) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*Secret) Set

func (v *Secret) Set(s string) error

Set implements flag.Value

func (Secret) String

func (v Secret) String() string

String implements flag.Value

func (*Secret) UnmarshalYAML

func (v *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

type StringSlice

type StringSlice []string

StringSlice is a slice of strings that implements flag.Value

func (*StringSlice) Set

func (v *StringSlice) Set(s string) error

Set implements flag.Value

func (StringSlice) String

func (v StringSlice) String() string

String implements flag.Value

type StringSliceCSV

type StringSliceCSV []string

StringSliceCSV is a slice of strings that is parsed from a comma-separated string It implements flag.Value and yaml Marshalers

func (StringSliceCSV) MarshalYAML

func (v StringSliceCSV) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*StringSliceCSV) Set

func (v *StringSliceCSV) Set(s string) error

Set implements flag.Value

func (StringSliceCSV) String

func (v StringSliceCSV) String() string

String implements flag.Value

func (*StringSliceCSV) UnmarshalYAML

func (v *StringSliceCSV) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

type Time

type Time time.Time

Time usable as flag or in YAML config.

func (Time) MarshalYAML

func (t Time) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*Time) Set

func (t *Time) Set(s string) error

Set implements flag.Value

func (Time) String

func (t Time) String() string

String implements flag.Value

func (*Time) UnmarshalYAML

func (t *Time) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

type URLValue

type URLValue struct {
	*url.URL
}

URLValue is a url.URL that can be used as a flag.

func (URLValue) MarshalYAML

func (v URLValue) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*URLValue) Set

func (v *URLValue) Set(s string) error

Set implements flag.Value

func (URLValue) String

func (v URLValue) String() string

String implements flag.Value

func (*URLValue) UnmarshalYAML

func (v *URLValue) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

Jump to

Keyboard shortcuts

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