Documentation ¶
Overview ¶
Package flag is a thin layer over the stdlib flag package that provides some minimal features such as aliasing, autocompletion handling, improved defaults, etc. It was created for mitchellh/cli but can work as a standalone package.
Index ¶
- type BoolPtrVar
- type BoolVar
- type DurationVar
- type EnumSingleVar
- type EnumVar
- type FlagExample
- type FlagVisibility
- type Float64Var
- type Int64Var
- type IntVar
- type Set
- func (f *Set) BoolPtrVar(i *BoolPtrVar)
- func (f *Set) BoolVar(i *BoolVar)
- func (f *Set) DurationVar(i *DurationVar)
- func (f *Set) EnumSingleVar(i *EnumSingleVar)
- func (f *Set) EnumVar(i *EnumVar)
- func (f *Set) Float64Var(i *Float64Var)
- func (f *Set) Int64Var(i *Int64Var)
- func (f *Set) IntVar(i *IntVar)
- func (f *Set) Name() string
- func (f *Set) StringMapVar(i *StringMapVar)
- func (f *Set) StringSliceVar(i *StringSliceVar)
- func (f *Set) StringVar(i *StringVar)
- func (f *Set) Uint64Var(i *Uint64Var)
- func (f *Set) UintVar(i *UintVar)
- func (f *Set) Var(value flag.Value, name, usage string)
- func (f *Set) VarFlag(i *VarFlag)
- func (f *Set) Visit(fn func(*flag.Flag))
- func (f *Set) VisitAll(fn func(*flag.Flag))
- func (f *Set) VisitVars(fn func(*VarFlag))
- type Sets
- func (f *Sets) Args() []string
- func (f *Sets) Completions() complete.Flags
- func (fs *Sets) Help() string
- func (f *Sets) NewSet(name string) *Set
- func (f *Sets) Parse(args []string) error
- func (f *Sets) Parsed() bool
- func (f *Sets) Visit(fn func(*flag.Flag))
- func (fs *Sets) VisitSets(fn func(name string, set *Set))
- type StringMapVar
- type StringSliceVar
- type StringVar
- type Uint64Var
- type UintVar
- type VarFlag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoolPtrVar ¶ added in v0.7.0
type BoolPtrVar struct { Name string Aliases []string Usage string Hidden bool EnvVar string Target **bool Completion complete.Predictor SetHook func(val bool) }
-- BoolPtrVar and boolPtr BoolPtrVar is used to discern between values provided via CLI flags for "true", "false", and "not specified". Because of this there is no default value offered. If you want to use a boolean flag with a default, see flag_bool.go
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 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 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 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 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 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 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 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 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 (*Set) BoolPtrVar ¶ added in v0.7.0
func (f *Set) BoolPtrVar(i *BoolPtrVar)
func (*Set) DurationVar ¶
func (f *Set) DurationVar(i *DurationVar)
func (*Set) EnumSingleVar ¶
func (f *Set) EnumSingleVar(i *EnumSingleVar)
func (*Set) Float64Var ¶
func (f *Set) Float64Var(i *Float64Var)
func (*Set) StringMapVar ¶
func (f *Set) StringMapVar(i *StringMapVar)
func (*Set) StringSliceVar ¶
func (f *Set) StringSliceVar(i *StringSliceVar)
type Sets ¶
type Sets struct {
// contains filtered or unexported fields
}
Sets is a group of flag sets.
func (*Sets) Completions ¶
Completions returns the completions for this flag set.
func (*Sets) NewSet ¶
NewSet creates a new single flag set. A set should be created for any grouping of flags, for example "Common Options", "Auth Options", etc.
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 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 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 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