flags

package
v1.5.0-dev16 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayValueFlagFrom

func ArrayValueFlagFrom[T any](singleFlag func(*T) *ValueFlag[T]) func(*[]T) *ArrayValueFlag[T]

Converts a value flag into a flag that can accept multiple of the same value.

Types

type ArrayValueFlag

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

An ArrayValueFlag is like a ValueFlag except it will add the command line value into a slice of values, and hence can be used for flags that are meant to appear multiple times.

func NewIPFSStorageSpecArrayFlag

func NewIPFSStorageSpecArrayFlag(value *[]*models.InputSource) *ArrayValueFlag[*models.InputSource]

func NewURLStorageSpecArrayFlag

func NewURLStorageSpecArrayFlag(value *[]*models.InputSource) *ArrayValueFlag[*models.InputSource]

func ResultPathFlag added in v1.4.0

func ResultPathFlag(value *[]*models.ResultPath) *ArrayValueFlag[*models.ResultPath]

func (*ArrayValueFlag[T]) Set

func (s *ArrayValueFlag[T]) Set(input string) error

Set implements pflag.Value

func (*ArrayValueFlag[T]) String

func (s *ArrayValueFlag[T]) String() string

String implements pflag.Value

func (*ArrayValueFlag[T]) Type

func (s *ArrayValueFlag[T]) Type() string

Type implements pflag.Value

type KeyValueParser

type KeyValueParser[K comparable, V any] func(string) (K, V, error)

A KeyValueParser is like a Parser except that it returns two values representing a key and a value.

func SeparatorParser added in v1.2.0

func SeparatorParser(sep string) KeyValueParser[string, string]

type KeyValueStringer

type KeyValueStringer[K comparable, V any] func(*K, *V) string

A KeyValueStringer is like a Stringer except that it converts native objects representing a key and a value into a string.

type MapValueFlag

type MapValueFlag[K comparable, V any] struct {
	// contains filtered or unexported fields
}

A MapValueFlag is like a ValueFlag except it will add the command line value into a map of values, and hence can be used for flags that are meant to appear multiple times and represent a key-value structure.

func (*MapValueFlag[K, V]) Set

func (s *MapValueFlag[K, V]) Set(input string) error

Set implements pflag.Value

func (*MapValueFlag[K, V]) String

func (s *MapValueFlag[K, V]) String() string

String implements pflag.Value

func (*MapValueFlag[K, V]) Type

func (s *MapValueFlag[K, V]) Type() string

Type implements pflag.Value

type Parser

type Parser[T any] func(string) (T, error)

A Parser is a function that can convert a string into a native object.

type Stringer

type Stringer[T any] func(*T) string

A Stringer is a function that can convert a native object into a string.

type TargetingMode added in v1.5.0

type TargetingMode bool
const (
	TargetAny TargetingMode = false
	TargetAll TargetingMode = true
)

func ParseTargetingMode added in v1.5.0

func ParseTargetingMode(s string) (TargetingMode, error)

func (TargetingMode) String added in v1.5.0

func (t TargetingMode) String() string

type ValueFlag

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

A ValueFlag is a pflag.Value that knows how to take a command line value represented as a string and set it as a native object into a struct.

func LoggingFlag

func LoggingFlag(value *logger.LogMode) *ValueFlag[logger.LogMode]

func NetworkFlag

func NetworkFlag(value *models.Network) *ValueFlag[models.Network]

func OutputFormatFlag

func OutputFormatFlag(value *output.OutputFormat) *ValueFlag[output.OutputFormat]

func TargetingFlag

func TargetingFlag(value *TargetingMode) *ValueFlag[TargetingMode]

func (*ValueFlag[T]) Set

func (s *ValueFlag[T]) Set(input string) error

Set implements pflag.Value

func (*ValueFlag[T]) String

func (s *ValueFlag[T]) String() string

String implements pflag.Value

func (*ValueFlag[T]) Type

func (s *ValueFlag[T]) Type() string

Type implements pflag.Value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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