flags

package
v0.0.0-...-4b634d0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidGenerator = errors.New("invalid generator")

ErrInvalidGenerator is raised when an unknown generator is set.

View Source
var ErrInvalidLogFormat = errors.New("invalid log format")

ErrInvalidLogFormat is raised when an unknown format is set.

View Source
var ErrInvalidLogLevel = errors.New("invalid log level")

ErrInvalidLogLevel is raised when an unknown level is set.

View Source
var ErrInvalidType = errors.New("accessed flag type does not match")

ErrInvalidType is raised when user tries to get a value from a flag of a different type.

View Source
var ErrUndefined = errors.New("flag accessed but not defined")

ErrUndefined is raised when user tries to access an undefined flag.

Functions

func BashCompletionDistribution

func BashCompletionDistribution(cmd *cobra.Command, f *pflag.FlagSet, name string) error

BashCompletionDistribution adds bash completion to a distribution flag.

func BashCompletionLogFormat

func BashCompletionLogFormat(cmd *cobra.Command, f *pflag.FlagSet, name string) error

BashCompletionLogFormat adds bash completion to a distribution flag.

func BashCompletionLogLevel

func BashCompletionLogLevel(cmd *cobra.Command, f *pflag.FlagSet, name string) error

BashCompletionLogLevel adds bash completion to a distribution flag.

func ChoicesString

func ChoicesString(choices []string) string

ChoicesString converts choices list into printable text.

func DistributionChoices

func DistributionChoices() []string

DistributionChoices returns a string representation of available generators.

func GetConstraints

func GetConstraints(f *pflag.FlagSet, name string) ([]*tester.Constraint, error)

GetConstraints returns a constraints from a pflag set.

func GetConstraintsValue

func GetConstraintsValue(v pflag.Value) ([]*tester.Constraint, error)

GetConstraintsValue returns a constraints from a pflag value.

func GetGrowth

func GetGrowth(f *pflag.FlagSet, name string) (tester.Growth, error)

GetGrowth returns a growth from a pflag set.

func GetGrowthValue

func GetGrowthValue(v pflag.Value) (tester.Growth, error)

GetGrowthValue returns a growth from a pflag value.

func LogFormatChoices

func LogFormatChoices() []string

LogFormatChoices returns a string representation of available formats.

func LogLevelChoices

func LogLevelChoices() []string

LogLevelChoices returns a string representation of available levels.

Types

type ConstraintSliceValue

type ConstraintSliceValue struct {
	Parsers []tester.MetricParser
	// contains filtered or unexported fields
}

ConstraintSliceValue is a pflag value storing constraints.

func NewConstraintSliceValue

func NewConstraintSliceValue(parsers ...tester.MetricParser) *ConstraintSliceValue

NewConstraintSliceValue creates a new constraint slice value for pflag.

func (*ConstraintSliceValue) Set

func (c *ConstraintSliceValue) Set(value string) error

Set validates given string given constraints and parses them to constraint structures using metric parsers.

func (*ConstraintSliceValue) String

func (c *ConstraintSliceValue) String() string

func (*ConstraintSliceValue) Type

func (c *ConstraintSliceValue) Type() string

Type returns the ConstraintSliceValue Type.

type Distribution

type Distribution struct {
	Name string
	// contains filtered or unexported fields
}

Distribution represents a interval generator flag value.

func NewDefaultDistribution

func NewDefaultDistribution() *Distribution

NewDefaultDistribution returns new distribution flag with default values.

func (*Distribution) Get

Get returns a distibution generator.

func (*Distribution) Set

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

Set validates a given value and sets distribution (allows prefix matching).

func (*Distribution) String

func (d *Distribution) String() string

func (*Distribution) Type

func (d *Distribution) Type() string

Type returns a distribution type.

type DistributionGenerator

type DistributionGenerator = func(float64) bender.IntervalGenerator

DistributionGenerator represents distribution generator function.

func GetDistribution

func GetDistribution(f *pflag.FlagSet, name string) (DistributionGenerator, error)

GetDistribution returns a distribution from a pflag set.

func GetDistributionValue

func GetDistributionValue(v pflag.Value) (DistributionGenerator, error)

GetDistributionValue returns a distribution from a pflag value.

type GrowthValue

type GrowthValue struct {
	Growth tester.Growth
}

GrowthValue represents growth flag value.

func (*GrowthValue) Set

func (g *GrowthValue) Set(value string) error

Set validates a given growth and saves it.

func (*GrowthValue) String

func (g *GrowthValue) String() string

func (*GrowthValue) Type

func (g *GrowthValue) Type() string

Type returns a growth value type.

type LogFormat

type LogFormat struct {
	Logger *logrus.Logger
	Format string
}

LogFormat represents a log format flag value.

func (*LogFormat) Set

func (l *LogFormat) Set(value string) error

Set validates a given value and sets log format.

func (*LogFormat) String

func (l *LogFormat) String() string

func (*LogFormat) Type

func (l *LogFormat) Type() string

Type returns a log format value type.

type LogLevel

type LogLevel struct {
	Logger *logrus.Logger
}

LogLevel represents a log level flag value.

func (*LogLevel) Set

func (l *LogLevel) Set(value string) error

Set validates a given value and sets log level.

func (*LogLevel) String

func (l *LogLevel) String() string

func (*LogLevel) Type

func (l *LogLevel) Type() string

Type returns a log level value type.

type LogOutput

type LogOutput struct {
	Logger   *logrus.Logger
	Filename string
	Out      *os.File
}

LogOutput represents a log output flag value.

func NewLogOutput

func NewLogOutput(logger *logrus.Logger) *LogOutput

NewLogOutput returns new log output flag Value.

func (*LogOutput) Set

func (l *LogOutput) Set(value string) error

Set opens the file and sets the Out of the Logger.

func (*LogOutput) String

func (l *LogOutput) String() string

func (*LogOutput) Type

func (l *LogOutput) Type() string

Type returns a log output value type.

Jump to

Keyboard shortcuts

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