flag

package
v0.0.1-techpreview1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolVar

type BoolVar struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    bool
	Hidden     bool
	EnvVar     string
	Target     *bool
	Completion complete.Predictor
	SetHook    func(val bool)
}

-- BoolVar and boolValue

type BoolVarP

type BoolVarP struct {
	*BoolVar
	Shorthand string
}

type DurationVar

type DurationVar struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    time.Duration
	Hidden     bool
	EnvVar     string
	Target     *time.Duration
	Completion complete.Predictor
}

-- DurationVar and durationValue

type DurationVarP

type DurationVarP struct {
	*DurationVar
	Shorthand string
}

type EnumSingleVar

type EnumSingleVar struct {
	Name       string
	Aliases    []string
	Usage      string
	Values     []string
	Default    string
	Hidden     bool
	EnvVar     string
	Target     *string
	SetHook    func(val string)
	Completion complete.Predictor
}

-- EnumVar and enumValue

type EnumSingleVarP

type EnumSingleVarP struct {
	*EnumSingleVar
	Shorthand string
}

type EnumVar

type EnumVar struct {
	Name       string
	Aliases    []string
	Usage      string
	Values     []string
	Default    []string
	Hidden     bool
	EnvVar     string
	Target     *[]string
	Completion complete.Predictor
}

-- EnumVar and enumValue

type EnumVarP

type EnumVarP struct {
	*EnumVar
	Shorthand string
}

type FlagExample

type FlagExample interface {
	Example() string
}

FlagExample is an interface which declares an example value. This is used in help generation to provide better help text.

type FlagValue

type FlagValue interface {
	String() string
	Set(string) error
	Type() string
}

type FlagVisibility

type FlagVisibility interface {
	Hidden() bool
}

FlagVisibility is an interface which declares whether a flag should be hidden from help and completions. This is usually used for deprecations on "internal-only" flags.

type Float64Var

type Float64Var struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    float64
	Hidden     bool
	EnvVar     string
	Target     *float64
	Completion complete.Predictor
}

-- Float64Var and float64Value

type Float64VarP

type Float64VarP struct {
	*Float64Var
	Shorthand string
}

type Int64Var

type Int64Var struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    int64
	Hidden     bool
	EnvVar     string
	Target     *int64
	Completion complete.Predictor
	SetHook    func(val int64)
}

-- Int64Var and int64Value

type Int64VarP

type Int64VarP struct {
	*Int64Var
	Shorthand string
}

type IntVar

type IntVar struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    int
	Hidden     bool
	EnvVar     string
	Target     *int
	Completion complete.Predictor
	SetHook    func(val int)
}

-- IntVar and intValue

type IntVarP

type IntVarP struct {
	*IntVar
	Shorthand string
}

type Set

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

Set is a grouped wrapper around a real flag set and a grouped flag set.

func NewSet

func NewSet(name string) *Set

NewSet creates a new flag set.

func (*Set) BoolVar

func (f *Set) BoolVar(i *BoolVar)

func (*Set) BoolVarP

func (f *Set) BoolVarP(i *BoolVarP)

func (*Set) DurationVar

func (f *Set) DurationVar(i *DurationVar)

func (*Set) DurationVarP

func (f *Set) DurationVarP(i *DurationVarP)

func (*Set) EnumSingleVar

func (f *Set) EnumSingleVar(i *EnumSingleVar)

func (*Set) EnumSingleVarP

func (f *Set) EnumSingleVarP(i *EnumSingleVarP)

func (*Set) EnumVar

func (f *Set) EnumVar(i *EnumVar)

func (*Set) EnumVarP

func (f *Set) EnumVarP(i *EnumVarP)

func (*Set) Float64Var

func (f *Set) Float64Var(i *Float64Var)

func (*Set) Float64VarP

func (f *Set) Float64VarP(i *Float64VarP)

func (*Set) Int64Var

func (f *Set) Int64Var(i *Int64Var)

func (*Set) Int64VarP

func (f *Set) Int64VarP(i *Int64VarP)

func (*Set) IntVar

func (f *Set) IntVar(i *IntVar)

func (*Set) IntVarP

func (f *Set) IntVarP(i *IntVarP)

func (*Set) Name

func (f *Set) Name() string

Name returns the name of this flag set.

func (*Set) StringMapVar

func (f *Set) StringMapVar(i *StringMapVar)

func (*Set) StringMapVarP

func (f *Set) StringMapVarP(i *StringMapVarP)

func (*Set) StringSliceVar

func (f *Set) StringSliceVar(i *StringSliceVar)

func (*Set) StringSliceVarP

func (f *Set) StringSliceVarP(i *StringSliceVarP)

func (*Set) StringVar

func (f *Set) StringVar(i *StringVar)

func (*Set) StringVarP

func (f *Set) StringVarP(i *StringVarP)

func (*Set) Uint64Var

func (f *Set) Uint64Var(i *Uint64Var)

func (*Set) Uint64VarP

func (f *Set) Uint64VarP(i *Uint64VarP)

func (*Set) UintVar

func (f *Set) UintVar(i *UintVar)

func (*Set) UintVarP

func (f *Set) UintVarP(i *UintVarP)

func (*Set) Var

func (f *Set) Var(value flag.Value, name, usage string)

Var is a lower-level API for adding something to the flags. It should be used wtih caution, since it bypasses all validation. Consider VarFlag instead.

func (*Set) VarFlag

func (f *Set) VarFlag(i *VarFlag)

func (*Set) VarFlagP

func (f *Set) VarFlagP(i *VarFlagP)

func (*Set) VarP

func (f *Set) VarP(value flag.Value, name, shorthand, usage string)

func (*Set) Visit

func (f *Set) Visit(fn func(*flag.Flag))

func (*Set) VisitAll

func (f *Set) VisitAll(fn func(*flag.Flag))

func (*Set) VisitVars

func (f *Set) VisitVars(fn func(*VarFlagP))

type Sets

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

Sets is a group of flag sets.

func NewSets

func NewSets() *Sets

NewSets creates a new flag sets.

func (*Sets) Args

func (f *Sets) Args() []string

Args returns the remaining args after parsing.

func (*Sets) Completions

func (f *Sets) Completions() complete.Flags

Completions returns the completions for this flag set.

func (*Sets) Help

func (fs *Sets) Help() string

Help builds custom help for this command, grouping by flag set.

func (*Sets) HideUnusedFlags

func (fs *Sets) HideUnusedFlags(setName string, flagNames []string)

TODO make this less horrendous my eyes are bleeding

func (*Sets) NewSet

func (f *Sets) NewSet(name string) *Set

NewSet creates a new single flag set. A set should be created for any grouping of flags, for example "Common Options", "Auth Options", etc.

func (*Sets) Parse

func (f *Sets) Parse(args []string) error

Parse parses the given flags, returning any errors. It does a naive check for std lib flags to determine which flag set to parse.

func (*Sets) Parsed

func (f *Sets) Parsed() bool

Parsed reports whether the command-line flags have been parsed.

func (*Sets) UsesGoflags

func (f *Sets) UsesGoflags() bool

Returns whether the command is using the parsed goflag set or posix set

func (*Sets) Visit

func (f *Sets) Visit(fn func(*flag.Flag))

Visit visits the flags in lexicographical order, calling fn for each. It visits only those flags that have been set.

func (*Sets) VisitSets

func (fs *Sets) VisitSets(fn func(name string, set *Set))

Help builds custom help for this command, grouping by flag set.

type StringMapVar

type StringMapVar struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    map[string]string
	Hidden     bool
	Target     *map[string]string
	Completion complete.Predictor
}

-- StringMapVar and stringMapValue

type StringMapVarP

type StringMapVarP struct {
	*StringMapVar
	Shorthand string
}

type StringSliceVar

type StringSliceVar struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    []string
	Hidden     bool
	EnvVar     string
	Target     *[]string
	Completion complete.Predictor
}

-- StringSliceVar and stringSliceValue

type StringSliceVarP

type StringSliceVarP struct {
	*StringSliceVar
	Shorthand string
}

type StringVar

type StringVar struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    string
	Hidden     bool
	EnvVar     string
	Target     *string
	Completion complete.Predictor
	SetHook    func(val string)
}

-- StringVar and stringValue

type StringVarP

type StringVarP struct {
	*StringVar
	Shorthand string
}

type Uint64Var

type Uint64Var struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    uint64
	Hidden     bool
	EnvVar     string
	Target     *uint64
	Completion complete.Predictor
	SetHook    func(val uint64)
}

-- Uint64Var and uint64Value

type Uint64VarP

type Uint64VarP struct {
	*Uint64Var
	Shorthand string
}

type UintVar

type UintVar struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    uint
	Hidden     bool
	EnvVar     string
	Target     *uint
	Completion complete.Predictor
	SetHook    func(val uint)
}

-- UintVar && uintValue

type UintVarP

type UintVarP struct {
	*UintVar
	Shorthand string
}

type VarFlag

type VarFlag struct {
	Name       string
	Aliases    []string
	Usage      string
	Default    string
	EnvVar     string
	Value      flag.Value
	Completion complete.Predictor
}

-- VarFlag

type VarFlagP

type VarFlagP struct {
	*VarFlag
	Shorthand string
}

Jump to

Keyboard shortcuts

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