flag

package
v5.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DateTimeFormat describes a short format supported by the flag
	DateTimeFormat = "2006.01.02-15:04"
	// DateTimeFormatTz describes long format supported by the flag
	DateTimeFormatTz = "2006.01.02-15:04:05-MST"

	// DateTimeExampleFormat is an exemplary valid datetime flag
	DateTimeExampleFormat = "2006.01.28-15:30"
	// DateTimeFormatDescr contains a description of the supported formats
	DateTimeFormatDescr = "YYYY.MM.DD-HH:MM[:SS-TZ]"
)
View Source
const (
	FormatFlagName = "format"
	FormatCSV      = "csv"
	FormatJSON     = "json"
	FormatPlain    = "plain"
)
View Source
const FieldSep = ","

FieldSep specifies the separator when passing multiple values to the flag

View Source
const TaskStatusFormatDescription string = "one of " +
	taskStatusExist + ", " +
	taskStatusPending

TaskStatusFormatDescription is the format description for the flag

Variables

This section is empty.

Functions

This section is empty.

Types

type DateTimeFlagValue

type DateTimeFlagValue struct {
	time.Time
}

DateTimeFlagValue is the DateTime pflag flag

func (*DateTimeFlagValue) Set

func (v *DateTimeFlagValue) Set(timeStr string) error

Set implements the pflag.Value interface

func (*DateTimeFlagValue) String

func (v *DateTimeFlagValue) String() string

String returns the default value in the usage output

func (*DateTimeFlagValue) Type

func (*DateTimeFlagValue) Type() string

Type returns the value description string

type Fields

type Fields struct {
	Fields []string
	// contains filtered or unexported fields
}

Fields is a flag that accept a comma-separated list of field names. The passed values are case-insensitive.

func MustNewFields

func MustNewFields(supportedFields, defaultFields []string) *Fields

MustNewFields returns a new flag that supports the passed fields. The default value of the flag is specified by defaultFields. If an element is in defaultFields but not in supportedFields the function panics.

func (*Fields) Set

func (f *Fields) Set(val string) error

Set parses a list of fields, fields contained in the string are set to true, all others are set to fault. If an unrecognized option value is passed a error is returned

func (*Fields) String

func (f *Fields) String() string

String returns the list of enabled fields. It is used to show the default value in the usage output.

func (*Fields) Type

func (f *Fields) Type() string

Type returns the format description

func (*Fields) Usage

func (f *Fields) Usage(highlightFn func(a ...any) string) string

Usage returns a usage description, important parts are passed through highlightFn

func (*Fields) ValidValues

func (f *Fields) ValidValues() string

ValidValues returns the values that the flag accepts

type Format

type Format struct {
	Val string
}

type OneOf

type OneOf struct {
	Val string
	// contains filtered or unexported fields
}

OneOf is a command line flag that accepts one of multiple possible values.

func NewFormatFlag

func NewFormatFlag() *OneOf

func NewOneOfFlag

func NewOneOfFlag(flagName, defaultVal, usage string, supportedVals ...string) *OneOf

func (*OneOf) RegisterFlagCompletion

func (f *OneOf) RegisterFlagCompletion(cmd *cobra.Command) error

func (*OneOf) Set

func (f *OneOf) Set(val string) error

func (*OneOf) String

func (f *OneOf) String() string

func (*OneOf) Type

func (f *OneOf) Type() string

func (*OneOf) Usage

func (f *OneOf) Usage(highlightFn func(a ...any) string) string

func (*OneOf) Value

func (f *OneOf) Value() string

type Sort

type Sort struct {
	Value storage.Sorter
	// contains filtered or unexported fields
}

Sort is a commandline flag to specify via which field and in which order output should be sorted

func NewSort

func NewSort(validFields map[string]storage.Field) *Sort

NewSort returns a Sort flag. The keys in the validFields maps are accepted as value for Fields and map to the storage.Field values.

func (*Sort) Set

func (s *Sort) Set(sortStr string) error

Set parses the passed string and sets the Sort

func (*Sort) String

func (s *Sort) String() string

String returns the default value in the usage output

func (*Sort) Type

func (s *Sort) Type() string

Type returns the format description

func (*Sort) Usage

func (s *Sort) Usage(highlightFn func(a ...any) string) string

Usage returns a usage description, important parts are passed through highlightFn

type TaskStatus

type TaskStatus struct {
	Status baur.TaskStatus
	// contains filtered or unexported fields
}

TaskStatus is a commandline parameter to specify build status filters

func (*TaskStatus) IsSet

func (b *TaskStatus) IsSet() bool

IsSet returns true if the flag parsed a commandline value (Set() was called)

func (*TaskStatus) Set

func (b *TaskStatus) Set(val string) error

Set parses the passed string and sets the SortFlagValue

func (*TaskStatus) String

func (b *TaskStatus) String() string

String returns the default value in the usage output

func (*TaskStatus) Type

func (b *TaskStatus) Type() string

Type returns the format description of the flag

func (*TaskStatus) Usage

func (b *TaskStatus) Usage(highlightFn func(a ...any) string) string

Usage returns a usage description, important parts are passed through highlightFn

Jump to

Keyboard shortcuts

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