cli

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

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

CLI represents command line interface for the operator.

func New

func New(m metadata.Info) *CLI

New returns a new CLI.

func (*CLI) FlagSet

func (c *CLI) FlagSet() *flag.FlagSet

FlagSet returns bare underlying flagset of the cli. It can be used to register additional flags. They will be parsed by Parse() method. Caller needs to take care of values set by flags added to this flagset.

func (*CLI) Metadata added in v1.3.0

func (c *CLI) Metadata() metadata.Info

Metadata returns the metadata for the controller manager.

func (*CLI) Parse

func (c *CLI) Parse(arguments []string) manager.Config

Parse parses flag definitions from the argument list, which should not include the command name. Must be called after all additional flags in the FlagSet() are defined and before flags are accessed by the program. It returns config for controller manager.

type ValidatedValue added in v1.6.0

type ValidatedValue[T any] struct {
	// contains filtered or unexported fields
}

ValidatedValue implements `pflag.Value` interface. It can be used for hooking up arbitrary validation logic to any type. It should be passed to `pflag.FlagSet.Var()`.

func NewValidatedValue added in v1.6.0

func NewValidatedValue[T any](variable *T, constructor func(flagValue string) (T, error), opts ...ValidatedValueOpt[T]) ValidatedValue[T]

NewValidatedValue creates a validated variable of type T. Constructor should validate the input and return an error in case of any failures. If validation passes, constructor should return a value that's to be set in the variable. The constructor accepts a flagValue that is raw input from user's command line (or an env variable that was bind to the flag, see: bindEnvVars). It accepts a variadic list of options that can be used e.g. to set the default value or override the type name.

func (ValidatedValue[T]) Set added in v1.6.0

func (v ValidatedValue[T]) Set(s string) error

Set sets the value of the variable. It uses the constructor to validate the input and set the value.

func (ValidatedValue[T]) String added in v1.6.0

func (v ValidatedValue[T]) String() string

func (ValidatedValue[T]) Type added in v1.6.0

func (v ValidatedValue[T]) Type() string

Type returns the type of the variable. If the type name is overridden, it returns that.

type ValidatedValueOpt added in v1.6.0

type ValidatedValueOpt[T any] func(*ValidatedValue[T])

ValidatedValueOpt is a function that modifies a ValidatedValue.

func WithDefault added in v1.6.0

func WithDefault[T any](defaultValue T) ValidatedValueOpt[T]

WithDefault sets the default value for the validated variable.

func WithTypeNameOverride added in v1.6.0

func WithTypeNameOverride[T any](typeName string) ValidatedValueOpt[T]

WithTypeNameOverride overrides the type name that's printed in the help message.

Jump to

Keyboard shortcuts

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