flagutil

package
v1.67.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: Apache-2.0 Imports: 7 Imported by: 43

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSecretFlag added in v1.41.1

func IsSecretFlag(s string) bool

IsSecretFlag returns true of s contains flag name with secret value, which shouldn't be exposed.

func RegisterSecretFlag added in v1.41.1

func RegisterSecretFlag(flagName string)

RegisterSecretFlag registers flagName as secret.

This function must be called before starting logging. It cannot be called from concurrent goroutines.

Secret flags aren't exported at `/metrics` page.

func Usage added in v1.49.0

func Usage(s string)

Usage prints s and optional description for all the flags if -h or -help flag is passed to the app.

Types

type Array

type Array []string

Array is a flag that holds an array of values.

It may be set either by specifying multiple flags with the given name passed to NewArray or by joining flag values by comma.

The following example sets equivalent flag array with two items (value1, value2):

-foo=value1 -foo=value2
-foo=value1,value2

Flag values may be quoted. For instance, the following arg creates an array of ("a", "b, c") items:

-foo='a,"b, c"'

func NewArray added in v1.34.0

func NewArray(name, description string) *Array

NewArray returns new Array with the given name and description.

func (*Array) GetOptionalArg added in v1.35.3

func (a *Array) GetOptionalArg(argIdx int) string

GetOptionalArg returns optional arg under the given argIdx.

func (*Array) Set

func (a *Array) Set(value string) error

Set implements flag.Value interface

func (*Array) String

func (a *Array) String() string

String implements flag.Value interface

type ArrayBool added in v1.50.0

type ArrayBool []bool

ArrayBool is a flag that holds an array of booleans values. have the same api as Array.

func NewArrayBool added in v1.50.0

func NewArrayBool(name, description string) *ArrayBool

NewArrayBool returns new ArrayBool with the given name and description.

func (*ArrayBool) GetOptionalArg added in v1.50.0

func (a *ArrayBool) GetOptionalArg(argIdx int) bool

GetOptionalArg returns optional arg under the given argIdx.

func (*ArrayBool) IsBoolFlag added in v1.50.0

func (a *ArrayBool) IsBoolFlag() bool

IsBoolFlag implements flag.IsBoolFlag interface

func (*ArrayBool) Set added in v1.50.0

func (a *ArrayBool) Set(value string) error

Set implements flag.Value interface

func (*ArrayBool) String added in v1.50.0

func (a *ArrayBool) String() string

String implements flag.Value interface

type ArrayDuration added in v1.50.0

type ArrayDuration []time.Duration

ArrayDuration is a flag that holds an array of time.Duration values. have the same api as Array.

func NewArrayDuration added in v1.50.0

func NewArrayDuration(name, description string) *ArrayDuration

NewArrayDuration returns new ArrayDuration with the given name and description.

func (*ArrayDuration) GetOptionalArgOrDefault added in v1.50.0

func (a *ArrayDuration) GetOptionalArgOrDefault(argIdx int, defaultValue time.Duration) time.Duration

GetOptionalArgOrDefault returns optional arg under the given argIdx, or default value, if argIdx not found.

func (*ArrayDuration) Set added in v1.50.0

func (a *ArrayDuration) Set(value string) error

Set implements flag.Value interface

func (*ArrayDuration) String added in v1.50.0

func (a *ArrayDuration) String() string

String implements flag.Value interface

type ArrayInt added in v1.53.0

type ArrayInt []int

ArrayInt is flag that holds an array of ints.

func NewArrayInt added in v1.53.0

func NewArrayInt(name string, description string) *ArrayInt

NewArrayInt returns new ArrayInt with the given name and description.

func (*ArrayInt) GetOptionalArgOrDefault added in v1.53.0

func (a *ArrayInt) GetOptionalArgOrDefault(argIdx int, defaultValue int) int

GetOptionalArgOrDefault returns optional arg under the given argIdx.

func (*ArrayInt) Set added in v1.53.0

func (a *ArrayInt) Set(value string) error

Set implements flag.Value interface

func (*ArrayInt) String added in v1.53.0

func (a *ArrayInt) String() string

String implements flag.Value interface

type Bytes added in v1.40.1

type Bytes struct {
	// N contains parsed value for the given flag.
	N int
	// contains filtered or unexported fields
}

Bytes is a flag for holding size in bytes.

It supports the following optional suffixes for values: KB, MB, GB, KiB, MiB, GiB.

func NewBytes added in v1.40.1

func NewBytes(name string, defaultValue int, description string) *Bytes

NewBytes returns new `bytes` flag with the given name, defaultValue and description.

func (*Bytes) Set added in v1.40.1

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

Set implements flag.Value interface

func (*Bytes) String added in v1.40.1

func (b *Bytes) String() string

String implements flag.Value interface

type Duration added in v1.45.0

type Duration struct {
	// Msecs contains parsed duration in milliseconds.
	Msecs int64
	// contains filtered or unexported fields
}

Duration is a flag for holding duration.

func NewDuration added in v1.45.0

func NewDuration(name string, defaultValue float64, description string) *Duration

NewDuration returns new `duration` flag with the given name, defaultValue and description.

DefaultValue is in months.

func (*Duration) Set added in v1.45.0

func (d *Duration) Set(value string) error

Set implements flag.Value interface

func (*Duration) String added in v1.45.0

func (d *Duration) String() string

String implements flag.Value interface

Jump to

Keyboard shortcuts

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