Documentation ¶
Overview ¶
Package cli supports POSIX & GNU style cli flag parsing and command running.
Terminology ¶
- `args`: all strings provided to a cmd. For a root command in real world, it usually is `os.Args[1:]`
- `flags`: before the first dash, strings interpreted as flag names and flag values by POSIX and GNU style guide.
- `subcmds` (sub-commands): before the first dash, consecutive args matching a serial of `Cmd.Pattern`. In the below illustration, if there is a `Cmd` in root command's `Children []*Cmd` field whose `Cmd.Pattern` matches `xxx`, then the posArg `xxx` becomes subcmd `xxx`.
- `posArgs` (positional args): before the first dash, strings that are not flags and subcmds.
- `dashArgs`: all strings after the dash.
Illustration without subcmds:
dash | posArg flag name | | | | ./foo xxx -i --join bar -- other args | | [ all args after the dash are dashArgs] | | | flag value | flag shorthand, with implicit value
Index ¶
- func AssignFlagsDefaultValue(flags FlagIndexer, opts *ParseOptions) (err error)
- func FormatRoute(w io.Writer, route Route, sep string) (n int, err error)
- func HandleArgErrorAsHelpRequest(opts *CmdOptions, route Route, args []string, badArgAt int, cmdErr error) error
- func HandleHelpRequest(opts *CmdOptions, route Route, args []string, helpArgAt int) error
- func IsShorthand(s string) bool
- func ParseFlags(args []string, flags FlagFinder, opts *ParseOptions) (posArgs, dashArgs []string, err error)
- func ParseFlagsLowLevel(args []string, flags FlagFinder, opts *ParseOptions, offset int, ...) (nParsed int, posDash int, foundPosArg bool, posArgs []string, helpArgAt int, ...)
- func RuleContainsAny[R Rule](rule R, keys ...string) bool
- func RuleRequiresAny[R Rule](rule R, keys ...string) bool
- func WriteShellCompScriptBash(out io.Writer, rootCmdName, completionCmdName string) (int, error)
- func WriteShellCompScriptPwsh(out io.Writer, rootCmdName, completionCmdName string) (int, error)
- func WriteShellCompScriptZsh(out io.Writer, rootCmdName, completionCmdName string) (int, error)
- func WriteShellCompUsageBash(out io.Writer, rootCmdName, completionCmdName string) (int, error)
- func WriteShellCompUsagePwsh(out io.Writer, rootCmdName, completionCmdName string) (int, error)
- func WriteShellCompUsageZsh(out io.Writer, rootCmdName, completionCmdName string) (int, error)
- type AnyMaybeCompActionAndHelperTerminal
- type AnyMaybeHelperTerminal
- type ArgErrorHandleFunc
- type Bool
- type BoolSlice
- type BoolSliceV
- type BoolV
- type Cmd
- type CmdHelp
- type CmdOptions
- type CmdState
- type CompAction
- type CompActionDirs
- type CompActionDisable
- type CompActionFiles
- type CompActionFunc
- type CompActionStatic
- type CompCmdBash
- type CompCmdOpComplete
- type CompCmdPwsh
- type CompCmdShells
- type CompCmdZsh
- type CompFmt
- type CompFmtBash
- type CompFmtPwsh
- type CompFmtZsh
- type CompItem
- type CompKind
- type CompState
- func (c CompState) Done() bool
- func (c CompState) Failed() bool
- func (c CompState) HasDirs() bool
- func (c CompState) HasFiles() bool
- func (c CompState) HasFlagNames() bool
- func (c CompState) HasFlagValues() bool
- func (c CompState) HasSubcmds() bool
- func (c CompState) OptionNosort() bool
- func (c CompState) OptionNospace() bool
- type CompTask
- func (tsk *CompTask) Add(force bool, items ...CompItem) (added int)
- func (tsk *CompTask) AddDefault() (added int)
- func (tsk *CompTask) AddDirs(force bool, globs ...string) (added int)
- func (tsk *CompTask) AddFiles(force bool, globs ...string) (added int)
- func (tsk *CompTask) AddFlagNames(force bool, flags FlagIndexer, descr bool) (added int)
- func (tsk *CompTask) AddFlagValues(force bool, flag Flag, def string, addDefaults bool) (added int)
- func (tsk *CompTask) AddMatched(force bool, items ...CompItem) (added int)
- func (tsk *CompTask) AddSubcmds(force bool, cmd *Cmd, descr bool) (added int)
- func (tsk *CompTask) Debug(msgs ...string)
- func (tsk *CompTask) Done()
- func (tsk *CompTask) Fail()
- func (tsk *CompTask) Init(root *Cmd, opts *CmdOptions, at int, args ...string)
- func (tsk *CompTask) Nth(i int) (CompItem, bool)
- func (tsk *CompTask) RawToComplete() string
- func (tsk *CompTask) SetDebugOutput(out io.Writer)
- func (tsk *CompTask) State() CompState
- func (tsk *CompTask) Want() CompState
- type DefaultReflectVPFactory
- type Duration
- type DurationSlice
- type DurationSliceV
- type DurationSum
- type DurationSumV
- type DurationV
- type ErrAmbiguousArgs
- type ErrCmdNotRunnable
- type ErrDuplicateFlag
- type ErrEmptyRoute
- type ErrFlagSetAtMostOnce
- type ErrFlagUndefined
- type ErrFlagValueInvalid
- type ErrFlagValueMissing
- type ErrHelpHandled
- type ErrHelpPending
- type ErrInvalidValue
- type ErrShorthandOfExplicitFlagInMiddle
- type ErrTimeout
- type ErrUnsupportedType
- type Flag
- type FlagBase
- func (f *FlagBase[T, P]) Decode(opts *ParseOptions, name, arg string, set bool) error
- func (f *FlagBase[T, P]) Extra() any
- func (f *FlagBase[T, P]) HasValue() bool
- func (f *FlagBase[T, P]) ImplyValue() (string, bool)
- func (f *FlagBase[T, P]) PrintValue(out io.Writer) (int, error)
- func (f *FlagBase[T, P]) State() FlagState
- func (f *FlagBase[T, P]) Type() (string, bool)
- func (f *FlagBase[T, P]) Usage() string
- type FlagBaseV
- func (f *FlagBaseV[T, P]) Decode(opts *ParseOptions, name, arg string, set bool) error
- func (f *FlagBaseV[T, P]) Extra() any
- func (f *FlagBaseV[T, P]) HasValue() bool
- func (f *FlagBaseV[T, P]) ImplyValue() (string, bool)
- func (f *FlagBaseV[T, P]) PrintValue(out io.Writer) (int, error)
- func (f *FlagBaseV[T, P]) State() FlagState
- func (f *FlagBaseV[T, P]) Type() (string, bool)
- func (f *FlagBaseV[T, P]) Usage() string
- type FlagEmptyV
- func (f *FlagEmptyV) Decode(opts *ParseOptions, name, arg string, set bool) error
- func (f *FlagEmptyV) Extra() any
- func (f *FlagEmptyV) HasValue() bool
- func (f *FlagEmptyV) ImplyValue() (string, bool)
- func (f *FlagEmptyV) PrintValue(io.Writer) (int, error)
- func (f *FlagEmptyV) State() FlagState
- func (f *FlagEmptyV) Type() (string, bool)
- func (f *FlagEmptyV) Usage() string
- type FlagFinder
- type FlagFinderMaybeIter
- type FlagHelp
- type FlagIndexer
- type FlagInfo
- type FlagIter
- type FlagLevel
- type FlagReflect
- func (f *FlagReflect) Decode(opts *ParseOptions, name, arg string, set bool) error
- func (f *FlagReflect) Default() string
- func (f *FlagReflect) Extra() any
- func (f *FlagReflect) HasValue() bool
- func (f *FlagReflect) ImplyValue() (string, bool)
- func (f *FlagReflect) PrintValue(out io.Writer) (int, error)
- func (f *FlagReflect) State() FlagState
- func (f *FlagReflect) Suggest(tsk *CompTask) (added int, _ CompState)
- func (f *FlagReflect) Type() (string, bool)
- func (f *FlagReflect) Usage() string
- type FlagState
- type FlagViolation
- type Float32
- type Float32Slice
- type Float32SliceV
- type Float32Sum
- type Float32SumV
- type Float32V
- type Float64
- type Float64Slice
- type Float64SliceV
- type Float64Sum
- type Float64SumV
- type Float64V
- type FuncIndexer
- type HelpHandleFunc
- type HelperTerminal
- type Inspector
- type Int
- type Int16
- type Int16Slice
- type Int16SliceV
- type Int16Sum
- type Int16SumV
- type Int16V
- type Int32
- type Int32Slice
- type Int32SliceV
- type Int32Sum
- type Int32SumV
- type Int32V
- type Int64
- type Int64Slice
- type Int64SliceV
- type Int64Sum
- type Int64SumV
- type Int64V
- type Int8
- type Int8Slice
- type Int8SliceV
- type Int8Sum
- type Int8SumV
- type Int8V
- type IntSlice
- type IntSliceV
- type IntSum
- type IntSumV
- type IntV
- type LevelIndexer
- type MapIndexer
- type MapIntBool
- type MapIntBoolSlice
- type MapIntBoolSliceV
- type MapIntBoolV
- type MapIntDuration
- type MapIntDurationSlice
- type MapIntDurationSliceV
- type MapIntDurationSum
- type MapIntDurationSumV
- type MapIntDurationV
- type MapIntFloat32
- type MapIntFloat32Slice
- type MapIntFloat32SliceV
- type MapIntFloat32Sum
- type MapIntFloat32SumV
- type MapIntFloat32V
- type MapIntFloat64
- type MapIntFloat64Slice
- type MapIntFloat64SliceV
- type MapIntFloat64Sum
- type MapIntFloat64SumV
- type MapIntFloat64V
- type MapIntInt
- type MapIntInt16
- type MapIntInt16Slice
- type MapIntInt16SliceV
- type MapIntInt16Sum
- type MapIntInt16SumV
- type MapIntInt16V
- type MapIntInt32
- type MapIntInt32Slice
- type MapIntInt32SliceV
- type MapIntInt32Sum
- type MapIntInt32SumV
- type MapIntInt32V
- type MapIntInt64
- type MapIntInt64Slice
- type MapIntInt64SliceV
- type MapIntInt64Sum
- type MapIntInt64SumV
- type MapIntInt64V
- type MapIntInt8
- type MapIntInt8Slice
- type MapIntInt8SliceV
- type MapIntInt8Sum
- type MapIntInt8SumV
- type MapIntInt8V
- type MapIntIntSlice
- type MapIntIntSliceV
- type MapIntIntSum
- type MapIntIntSumV
- type MapIntIntV
- type MapIntRegexp
- type MapIntRegexpNocase
- type MapIntRegexpNocaseSlice
- type MapIntRegexpNocaseSliceV
- type MapIntRegexpNocaseV
- type MapIntRegexpSlice
- type MapIntRegexpSliceV
- type MapIntRegexpV
- type MapIntSize
- type MapIntSizeSlice
- type MapIntSizeSliceV
- type MapIntSizeSum
- type MapIntSizeSumV
- type MapIntSizeV
- type MapIntString
- type MapIntStringSlice
- type MapIntStringSliceV
- type MapIntStringV
- type MapIntTime
- type MapIntTimeSlice
- type MapIntTimeSliceV
- type MapIntTimeV
- type MapIntUint
- type MapIntUint16
- type MapIntUint16Slice
- type MapIntUint16SliceV
- type MapIntUint16Sum
- type MapIntUint16SumV
- type MapIntUint16V
- type MapIntUint32
- type MapIntUint32Slice
- type MapIntUint32SliceV
- type MapIntUint32Sum
- type MapIntUint32SumV
- type MapIntUint32V
- type MapIntUint64
- type MapIntUint64Slice
- type MapIntUint64SliceV
- type MapIntUint64Sum
- type MapIntUint64SumV
- type MapIntUint64V
- type MapIntUint8
- type MapIntUint8Slice
- type MapIntUint8SliceV
- type MapIntUint8Sum
- type MapIntUint8SumV
- type MapIntUint8V
- type MapIntUintSlice
- type MapIntUintSliceV
- type MapIntUintSum
- type MapIntUintSumV
- type MapIntUintV
- type MapIntUintptr
- type MapIntUintptrSlice
- type MapIntUintptrSliceV
- type MapIntUintptrSum
- type MapIntUintptrSumV
- type MapIntUintptrV
- type MapIntUnixMicro
- type MapIntUnixMicroSlice
- type MapIntUnixMicroSliceV
- type MapIntUnixMicroV
- type MapIntUnixMilli
- type MapIntUnixMilliSlice
- type MapIntUnixMilliSliceV
- type MapIntUnixMilliV
- type MapIntUnixNano
- type MapIntUnixNanoSlice
- type MapIntUnixNanoSliceV
- type MapIntUnixNanoV
- type MapIntUnixSec
- type MapIntUnixSecSlice
- type MapIntUnixSecSliceV
- type MapIntUnixSecV
- type MapStringBool
- type MapStringBoolSlice
- type MapStringBoolSliceV
- type MapStringBoolV
- type MapStringDuration
- type MapStringDurationSlice
- type MapStringDurationSliceV
- type MapStringDurationSum
- type MapStringDurationSumV
- type MapStringDurationV
- type MapStringFloat32
- type MapStringFloat32Slice
- type MapStringFloat32SliceV
- type MapStringFloat32Sum
- type MapStringFloat32SumV
- type MapStringFloat32V
- type MapStringFloat64
- type MapStringFloat64Slice
- type MapStringFloat64SliceV
- type MapStringFloat64Sum
- type MapStringFloat64SumV
- type MapStringFloat64V
- type MapStringInt
- type MapStringInt16
- type MapStringInt16Slice
- type MapStringInt16SliceV
- type MapStringInt16Sum
- type MapStringInt16SumV
- type MapStringInt16V
- type MapStringInt32
- type MapStringInt32Slice
- type MapStringInt32SliceV
- type MapStringInt32Sum
- type MapStringInt32SumV
- type MapStringInt32V
- type MapStringInt64
- type MapStringInt64Slice
- type MapStringInt64SliceV
- type MapStringInt64Sum
- type MapStringInt64SumV
- type MapStringInt64V
- type MapStringInt8
- type MapStringInt8Slice
- type MapStringInt8SliceV
- type MapStringInt8Sum
- type MapStringInt8SumV
- type MapStringInt8V
- type MapStringIntSlice
- type MapStringIntSliceV
- type MapStringIntSum
- type MapStringIntSumV
- type MapStringIntV
- type MapStringRegexp
- type MapStringRegexpNocase
- type MapStringRegexpNocaseSlice
- type MapStringRegexpNocaseSliceV
- type MapStringRegexpNocaseV
- type MapStringRegexpSlice
- type MapStringRegexpSliceV
- type MapStringRegexpV
- type MapStringSize
- type MapStringSizeSlice
- type MapStringSizeSliceV
- type MapStringSizeSum
- type MapStringSizeSumV
- type MapStringSizeV
- type MapStringString
- type MapStringStringSlice
- type MapStringStringSliceV
- type MapStringStringV
- type MapStringTime
- type MapStringTimeSlice
- type MapStringTimeSliceV
- type MapStringTimeV
- type MapStringUint
- type MapStringUint16
- type MapStringUint16Slice
- type MapStringUint16SliceV
- type MapStringUint16Sum
- type MapStringUint16SumV
- type MapStringUint16V
- type MapStringUint32
- type MapStringUint32Slice
- type MapStringUint32SliceV
- type MapStringUint32Sum
- type MapStringUint32SumV
- type MapStringUint32V
- type MapStringUint64
- type MapStringUint64Slice
- type MapStringUint64SliceV
- type MapStringUint64Sum
- type MapStringUint64SumV
- type MapStringUint64V
- type MapStringUint8
- type MapStringUint8Slice
- type MapStringUint8SliceV
- type MapStringUint8Sum
- type MapStringUint8SumV
- type MapStringUint8V
- type MapStringUintSlice
- type MapStringUintSliceV
- type MapStringUintSum
- type MapStringUintSumV
- type MapStringUintV
- type MapStringUintptr
- type MapStringUintptrSlice
- type MapStringUintptrSliceV
- type MapStringUintptrSum
- type MapStringUintptrSumV
- type MapStringUintptrV
- type MapStringUnixMicro
- type MapStringUnixMicroSlice
- type MapStringUnixMicroSliceV
- type MapStringUnixMicroV
- type MapStringUnixMilli
- type MapStringUnixMilliSlice
- type MapStringUnixMilliSliceV
- type MapStringUnixMilliV
- type MapStringUnixNano
- type MapStringUnixNanoSlice
- type MapStringUnixNanoSliceV
- type MapStringUnixNanoV
- type MapStringUnixSec
- type MapStringUnixSecSlice
- type MapStringUnixSecSliceV
- type MapStringUnixSecV
- type MultiIndexer
- type MultiRule
- type ParseErrorHandleFunc
- type ParseOptions
- type PostRunFunc
- type PreRunFunc
- type ReflectFlagRef
- type ReflectIndexer
- type ReflectVPFactory
- type Regexp
- type RegexpNocase
- type RegexpNocaseSlice
- type RegexpNocaseSliceV
- type RegexpNocaseV
- type RegexpSlice
- type RegexpSliceV
- type RegexpV
- type Route
- type Rule
- type RuleAllOf
- type RuleAllOrNone
- type RuleAny
- type RuleAnyOf
- type RuleDepends
- type RuleOneOf
- type RunFunc
- type Size
- type SizeSlice
- type SizeSliceV
- type SizeSum
- type SizeSumV
- type SizeV
- type String
- type StringSlice
- type StringSliceV
- type StringV
- type Time
- type TimeSlice
- type TimeSliceV
- type TimeV
- type Uint
- type Uint16
- type Uint16Slice
- type Uint16SliceV
- type Uint16Sum
- type Uint16SumV
- type Uint16V
- type Uint32
- type Uint32Slice
- type Uint32SliceV
- type Uint32Sum
- type Uint32SumV
- type Uint32V
- type Uint64
- type Uint64Slice
- type Uint64SliceV
- type Uint64Sum
- type Uint64SumV
- type Uint64V
- type Uint8
- type Uint8Slice
- type Uint8SliceV
- type Uint8Sum
- type Uint8SumV
- type Uint8V
- type UintSlice
- type UintSliceV
- type UintSum
- type UintSumV
- type UintV
- type Uintptr
- type UintptrSlice
- type UintptrSliceV
- type UintptrSum
- type UintptrSumV
- type UintptrV
- type UnixMicro
- type UnixMicroSlice
- type UnixMicroSliceV
- type UnixMicroV
- type UnixMilli
- type UnixMilliSlice
- type UnixMilliSliceV
- type UnixMilliV
- type UnixNano
- type UnixNanoSlice
- type UnixNanoSliceV
- type UnixNanoV
- type UnixSec
- type UnixSecSlice
- type UnixSecSliceV
- type UnixSecV
- type VP
- type VPBool
- type VPDuration
- type VPFloat
- type VPInt
- type VPMap
- type VPNop
- type VPPointer
- type VPReflectBool
- type VPReflectDuration
- type VPReflectFloat
- type VPReflectInt
- type VPReflectMap
- func (vp VPReflectMap[K, V]) HasValue(value *reflect.Value) bool
- func (vp VPReflectMap[K, V]) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
- func (vp VPReflectMap[K, V]) PrintValue(out io.Writer, value *reflect.Value) (n int, err error)
- func (vp VPReflectMap[K, V]) Type() VPType
- type VPReflectRegexp
- type VPReflectRegexpNocase
- func (VPReflectRegexpNocase) HasValue(v *reflect.Value) bool
- func (VPReflectRegexpNocase) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
- func (VPReflectRegexpNocase) PrintValue(out io.Writer, value *reflect.Value) (int, error)
- func (VPReflectRegexpNocase) Type() VPType
- type VPReflectSize
- type VPReflectSlice
- func (vp VPReflectSlice[EP]) HasValue(value *reflect.Value) bool
- func (vp VPReflectSlice[EP]) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
- func (vp VPReflectSlice[EP]) PrintValue(out io.Writer, value *reflect.Value) (n int, err error)
- func (vp VPReflectSlice[EP]) Type() VPType
- type VPReflectString
- type VPReflectSum
- type VPReflectTime
- type VPReflectUint
- type VPReflectUnixMicro
- type VPReflectUnixMilli
- type VPReflectUnixNano
- type VPReflectUnixSec
- type VPRegexp
- type VPRegexpNocase
- type VPSize
- type VPSlice
- type VPString
- type VPSum
- type VPTime
- type VPType
- type VPUint
- type VPUnixMicro
- type VPUnixMilli
- type VPUnixNano
- type VPUnixSec
- type Violation
- type ViolationCode
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignFlagsDefaultValue ¶
func AssignFlagsDefaultValue(flags FlagIndexer, opts *ParseOptions) (err error)
AssignFlagsDefaultValue iterates through all flags and call Flag.Decode on flags with default value (indicated by FlagInfo.DefaultValue) but without FlagStateValueChanged set (indicated by both FlagInfo.State and Flag.State()).
func FormatRoute ¶
FormatRoute writes all Cmd.Name() in the route with sep in between.
For the last Cmd in route (the target), it writes the complete Cmd.Pattern.
func HandleArgErrorAsHelpRequest ¶
func HandleArgErrorAsHelpRequest( opts *CmdOptions, route Route, args []string, badArgAt int, cmdErr error, ) error
HandleArgErrorAsHelpRequest prints the error and usage text of the target command to stderr, it tries to cast Cmd.Extra and Flag.Extra() as TerminalHelper to write messages.
func HandleHelpRequest ¶
func HandleHelpRequest( opts *CmdOptions, route Route, args []string, helpArgAt int, ) error
HandleHelpRequest calls HandleArgErrorAsHelpRequest with nil error.
func IsShorthand ¶
IsShorthand returns true if s is a single rune string and is not a hyphen.
func ParseFlags ¶
func ParseFlags(args []string, flags FlagFinder, opts *ParseOptions) (posArgs, dashArgs []string, err error)
ParseFlags parses args with options, where args are usually the os.Args[1:].
Return value posArgs are positional args, dashArgs are args after the first dash (`--`).
Known limitations:
Flags allow implicit value cannot accept valid standalone value prefixed with hyphen (`-`) due to ambiguity. e.g. `--foo -1` where flag `foo` is of type IntSum. To workaround, use `--foo=-1`.
Standalone dash (`--`) can never become flag value or positional arg. To workaround for flag value, use `--flag=--`. There is no workaround to make `--` as a posArg.
func ParseFlagsLowLevel ¶
func ParseFlagsLowLevel( args []string, flags FlagFinder, opts *ParseOptions, offset int, appendPosArgs bool, stopAtFirstPosArg bool, setFlagValue bool, posArgsBuf []string, ) ( nParsed int, posDash int, foundPosArg bool, posArgs []string, helpArgAt int, err error, )
ParseFlagsLowLevel is the low-level version of ParseFlags with more options for flag parsing control.
If appendPosArgs is false, this function doesn't append positional args to posArgs, so the return value posArgs will be exactly the same a posArgsBuf.
If stopAtFirstPosArg is true, this function returns on reaching the first positional arg (before the dash), that arg is not added to nParsed.
If len(opts.HelpArgs) > 0, this function returns on reaching the first flag that matches any of help flags, in which case, the return value helpArgAt is expected to be greater or equal to zero, and args[helpArgAt] is the arg triggered this return.
If setFlagValue is false, this function calls Flag.Decode() with set = false.
The return value nParsed is the count of args parsed, which includes the bad flag on error return (in which case there are nParsed-1 known good args).
The return value posDash is the index into args, when posDash >= 0, args[posDash] = "--" and args[posDash+1:] is dashArgs.
func RuleContainsAny ¶
func RuleRequiresAny ¶
func WriteShellCompScriptBash ¶
WriteShellCompScriptBash writes the bash completion script to out.
func WriteShellCompScriptPwsh ¶
WriteShellCompScriptBash writes the powershell completion script to out.
func WriteShellCompScriptZsh ¶
WriteShellCompScriptBash writes the zsh completion script to out.
func WriteShellCompUsageBash ¶
WriteShellCompScriptBash writes the usage of bash completion script to out.
func WriteShellCompUsagePwsh ¶
WriteShellCompScriptBash writes the usage of powershell completion script to out.
Types ¶
type AnyMaybeCompActionAndHelperTerminal ¶
type AnyMaybeCompActionAndHelperTerminal = any
AnyMaybeCompActionAndHelperTerminal is an alias of `any` and indicates some component may try to cast the value as a CompAction, HelperTerminal.
type AnyMaybeHelperTerminal ¶
type AnyMaybeHelperTerminal = any
AnyMaybeHelperTerminal is an alias of `any` and indicates some component will try to cast the value as a HelperTerminal.
type ArgErrorHandleFunc ¶
type ArgErrorHandleFunc = func( opts *CmdOptions, route Route, args []string, badArgAt int, argErr error, ) error
ArgErrorHandleFunc for args error.
route is the Cmd route from the root to the last known good Cmd.
args are the same args passed to Cmd.ResolveTarget
when badArgAt >= 0, it is where argErr happened, and args[badArgAt] is the bad arg.
Return nil to ignore the error.
type BoolSliceV ¶
predefined flag types for slice values from command line.
type Cmd ¶
type Cmd struct { // Pattern is supposed to be a one-line usage pattern of the command. // // Text before the first space is used for matching args in order to pick // this Cmd as sub-command, multiple names can be provided by joining with // pipe sign ('|'). // // As of the text after the first space, here is the recommended syntax: // // - `[ ]` to define an optional argument. // - `...` to allow multiple values for the previous arg. // - `|` to provide mutually exclusive options. // - `{ }` to define a group of mutually exclusive args. // // Example (where foo is the command name): // // foo|f [-F file | -D dir]... [-f {text|audio}] profile // // In the above example, `foo` is the command name and `f` is its alias. Pattern string // BriefUsage introduces the command briefly. BriefUsage string // Flags are flags accessible from both this Cmd and all its children. Flags FlagFinderMaybeIter // LocalFlags are flags only accessible from this Cmd. // // It is preferred to Flags for flag looking up. LocalFlags FlagFinderMaybeIter // FlagRule enforces certain rule to flags. FlagRule Rule // PreRun hook, see the type alias definition for parameter details. // // In Cmd.Exec, it is called from the root Cmd down to the target Cmd // before calling Run (even if the target Cmd's Run may be nil). PreRun PreRunFunc // Run, see the type alias definition for parameter details. // // In Cmd.Exec, it is called only when the owner Cmd is the target Cmd. Run RunFunc // PostRun hook, see the type alias definition for parameter details. // // In Cmd.Exec, it is called from that target Cmd up to the root Cmd after // the Run function returned. PostRun PostRunFunc // Help provides command specific help request handling. // // If not nil, it is called on help request for this command, otherwise // fallback to CmdOptions.HandleHelpRequest. Help HelpHandleFunc // Completion is the shell completion helper to suggest args for the // command. Completion CompAction // Extra stores application specific custom data. Extra AnyMaybeHelperTerminal // Children are sub-commands beloning to this Cmd. Children []*Cmd // State is Cmd's current state. State CmdState }
A Cmd represents a command.
TODO: define Command interface.
Example (CustomHelpArg) ¶
package main import ( "errors" "os" "regexp" "time" "github.com/primecitizens/cli" ) type Config struct { Subject string `cli:"s|subject,hide,#a simple string flag"` Dur *time.Duration `cli:"d|duration,value=dur,#example duration flag"` Size uint64 `cli:"size,value=size,def=32G,#size accepting common units"` Entries *[]string `cli:"e|entry,#log entries"` Metrics map[time.Duration]int `cli:"m|metric,key=dur,value=sum,#metrics summary"` Pattern []*regexp.Regexp `cli:"p|pattern,value=regexp,def=.*,def=^p,#regexp patterns"` } func main() { opts := &cli.CmdOptions{ ParseOptions: &cli.ParseOptions{ // define custom args can initiate help request. HelpArgs: []string{"-?", "why not?"}, }, Stderr: os.Stdout, // override stderr to work with golang example test // You can provide your own HelpHandleFunc, but here we use the one comes with // the library. HandleHelpRequest: cli.HandleHelpRequest, } root := cli.Cmd{ Pattern: "example -?", BriefUsage: "Just like all other indexers, terminal help also works with the ReflectIndexer", Flags: cli.NewReflectIndexer(cli.DefaultReflectVPFactory{}, &Config{ Subject: "Some default value deduced from flag state", }), } err := root.Exec(opts, "-?") if err != nil && !errors.Is(err, cli.ErrHelpHandled{}) { panic(err) } }
Output: example -? Just like all other indexers, terminal help also works with the ReflectIndexer Flags: -s --subject str (hidden) a simple string flag (default: Some default value deduced from flag state) -d --duration dur example duration flag --size size size accepting common units (default: 32G) -e --entry []str log entries -m --metric map[dur]isum metrics summary -p --pattern []regexp regexp patterns (default: [.*, ^p])
Example (MapIndexer) ¶
package main import ( "fmt" "github.com/primecitizens/cli" ) func main() { var ( str string flagB cli.BoolV flagI cli.IntV flagS = cli.String{ Value: &str, } ) root := &cli.Cmd{ Pattern: "example {print-flag-values|help|completion}", BriefUsage: "Using MapIndexer feels the same as a builder (but way more decentralized).", Flags: cli.NewMapIndexer(). Add(&flagB, "bool", "B"). Add(&flagI, "int", "I"). Add(&flagS, "string", "S"), LocalFlags: nil, FlagRule: cli.AllOf("bool", "int"), Completion: cli.CompActionFiles{}, Children: []*cli.Cmd{ { Pattern: "print-flag-values", Run: func(opts *cli.CmdOptions, route cli.Route, posArgs, dashArgs []string) error { fmt.Println("bool:", flagB.Value) fmt.Println("int:", flagI.Value) fmt.Println("string:", str) fmt.Println("posArgs:", posArgs) fmt.Println("dashArgs:", dashArgs) return nil }, }, (&cli.CompCmdShells{}).Setup("", -1, false), }, } err := root.Exec(&cli.CmdOptions{ HandleArgError: cli.HandleArgErrorAsHelpRequest, HandleHelpRequest: cli.HandleHelpRequest, }, "print-flag-values", "-BI", "10", "--string", "str", "pos1", "--", "dd1", ) if err != nil { panic(err) } }
Output: bool: true int: 10 string: str posArgs: [pos1] dashArgs: [dd1]
Example (ReflectIndexer) ¶
package main import ( "fmt" "regexp" "sort" "strings" "time" "github.com/primecitizens/cli" ) type Config struct { Subject string `cli:"s|subject,hide,#a simple string flag"` Dur *time.Duration `cli:"d|duration,value=dur,#example duration flag"` Size uint64 `cli:"size,value=size,def=32G,#size accepting common units"` Entries *[]string `cli:"e|entry,#log entries"` Metrics map[time.Duration]int `cli:"m|metric,key=dur,value=sum,#metrics summary"` Pattern []*regexp.Regexp `cli:"p|pattern,value=regexp,def=.*,def=^p,#regexp patterns"` } func run(opts *cli.CmdOptions, route cli.Route, posArgs, dashArgs []string) error { config := route.Root().Extra.(*Config) fmt.Println("After", config.Dur.Hours(), "hours,", config.Subject, "would have", config.Size, "bytes of data") fmt.Println("Some of the entries will be like:") fmt.Println(strings.Join(*config.Entries, "\n")) fmt.Println("Some of the metrics will be like:") var keys []time.Duration for k := range config.Metrics { keys = append(keys, k) } sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) for _, k := range keys { fmt.Println("[metric]", k.String(), "=", config.Metrics[k]) } return nil } func main() { var cfg Config root := cli.Cmd{ Pattern: "example", Flags: cli.NewReflectIndexer(cli.DefaultReflectVPFactory{}, &cfg), Run: run, Extra: &cfg, // run func will find this } err := root.Exec(nil, "-d", "32.5d", "--subject", "log file", "--size", "10T", "-e", "[app] err", "-e", "[app] fatal", "-m", "10s=2", "--metric", "10s=5", ) if err != nil { panic(err) } }
Output: After 780 hours, log file would have 10995116277760 bytes of data Some of the entries will be like: [app] err [app] fatal Some of the metrics will be like: [metric] 10s = 7
func (*Cmd) Exec ¶
func (c *Cmd) Exec(opts *CmdOptions, args ...string) (err error)
Exec tries to find and run the Cmd with longest matching Cmd.Pattern in args.
When called, this Cmd assumes itself as the root command.
func (*Cmd) ResolveTarget ¶
func (c *Cmd) ResolveTarget(opts *CmdOptions, args ...string) ( route Route, posArgs, dashArgs []string, err error, )
ResolveTarget walks the Cmd tree from c to the target Cmd by parsing args.
On a successful return, the `route` leads to the target Cmd with this Cmd being the first entry.
type CmdHelp ¶
type CmdHelp struct { // Example lists some typical use cases of the command. // // DO NOT include prefix like `Example: ` Example string // LongDescription is the detailed description of the command. LongDescription string // Experimental explains why the command is Experimental. // // Only use this field to note the reason of being experimental, and // DO NOT include prefix like `Experimental: ` Experimental string // Deprecation is the deprecation message of the command. // // Only use this message to note the reason of deprecation, and // DO NOT include prefix like `Deprecated: ` Deprecation string // Changelog may contain upgrade notice of the command. // // DO NOT include prefix like `Changelog: ` Changelog string // Extra custom data Extra any }
CmdHelp contains commonly used metadata for a cli command.
To produce consistent content, all values SHOULD NOT contain leading or trailling whitespaces.
Hint: use Cmd.Extra to hold *CmdHelp for documentation purpose.
type CmdOptions ¶
type CmdOptions struct { ParseOptions *ParseOptions // RouteBuf is the buffer for building the Cmd route. RouteBuf Route // Stdin is the stdin of the cmd. // // Defaults to nil. Stdin io.Reader // Stdout is the stdout of the cmd. // // Defaults to nil. Stdout io.Writer // Stderr is the stderr of the cmd. // // Defaults to nil. Stderr io.Writer // HandleArgError is the function get called to handle errors happened // during target resolving. HandleArgError ArgErrorHandleFunc // HandleHelpRequest is the fallback help request handle func. // // In a Cmd.Exec call, if both target Cmd.Help func and // CmdOptions.HandleHelpRequest are nil, no help will be provided. HandleHelpRequest HelpHandleFunc // Extra custom data. Extra any // SkipPostRun skips the Cmd.PostRun when set to true. SkipPostRun bool // DoNotSetFlags skips setting flag values. DoNotSetFlags bool }
CmdOptions are options for Cmd execution.
func (*CmdOptions) PickStderr ¶
func (c *CmdOptions) PickStderr(def ...io.Writer) io.Writer
PickStderr returns def if c.Stderr is nil.
func (*CmdOptions) PickStdin ¶
func (c *CmdOptions) PickStdin(def ...io.Reader) io.Reader
PickStdin returns def if c.Stdin is nil.
func (*CmdOptions) PickStdout ¶
func (c *CmdOptions) PickStdout(def ...io.Writer) io.Writer
PickStdout returns def if c.Stdout is nil.
type CmdState ¶
type CmdState uint32
const ( // CmdStateHidden hides the cmd from completion when set. CmdStateHidden CmdState = 1 << iota // CmdStatePreRunOnce to require the PreRun only gets called once. CmdStatePreRunOnce CmdStatePreRunCalled // CmdStatePostRunOnce to require the PostRun only gets called once. CmdStatePostRunOnce CmdStatePostRunCalled )
func (CmdState) PostRunCalled ¶
func (CmdState) PostRunOnce ¶
func (CmdState) PreRunCalled ¶
func (CmdState) PreRunOnce ¶
type CompAction ¶
type CompAction interface { // Suggest adds possible CompItems according to CompTask. Suggest(tsk *CompTask) (added int, state CompState) }
CompAction defines the interface for a completion action.
type CompActionDirs ¶
type CompActionDirs struct{}
CompActionDirs adds a CompItem to request dir completion.
func (CompActionDirs) Suggest ¶
func (CompActionDirs) Suggest(tsk *CompTask) (int, CompState)
Suggest implements CompAction.
type CompActionDisable ¶
type CompActionDisable struct{}
CompActionDisable marks the CompTask failed, so it can be used to disable the default completion behavior.
func (CompActionDisable) Suggest ¶
func (CompActionDisable) Suggest(tsk *CompTask) (int, CompState)
Suggest implements CompAction.
type CompActionFiles ¶
type CompActionFiles struct{}
CompActionFiles adds a CompItem to request file completion.
func (CompActionFiles) Suggest ¶
func (CompActionFiles) Suggest(tsk *CompTask) (int, CompState)
Suggest implements CompAction.
type CompActionFunc ¶
CompActionFunc wraps a function as Completion implementation.
func (CompActionFunc) Suggest ¶
func (fn CompActionFunc) Suggest(tsk *CompTask) (int, CompState)
Suggest implements CompAction.
type CompActionStatic ¶
CompActionStatic adds its predefined suggestions for completion request.
func (*CompActionStatic) Suggest ¶
func (s *CompActionStatic) Suggest(tsk *CompTask) (int, CompState)
Suggest implements CompAction.
type CompCmdBash ¶
type CompCmdBash struct {
// contains filtered or unexported fields
}
CompCmdBash is a bash completion command.
func (*CompCmdBash) Setup ¶
func (cc *CompCmdBash) Setup(opComplete *Cmd) *Cmd
Setup returns the prepared command.
opComplete is expected to be the return value of CompCmdOpComplete.Setup.
type CompCmdOpComplete ¶
type CompCmdOpComplete struct { // Timeout is the time limit to one completion request. Timeout DurationV // DebugFile is the file to write debug messages. DebugFile StringV // At is the position the cursor currently At. // // for zsh, it should be ($CURRENT - 1). // for bash, it should be $cword // for pwsh, it should be arg index base on $cursorPosition At UintV // contains filtered or unexported fields }
CompCmdOpComplete wraps the `complete` operation sub-command for type CompCmd{Bash, Zsh, Pwsh}.
It prepares the CompTask and invokes its parent Cmd to process the task.
func (*CompCmdOpComplete) FindFlag ¶
func (cc *CompCmdOpComplete) FindFlag(name string) (Flag, bool)
FindFlag implements FlagFinder.
func (*CompCmdOpComplete) NthFlag ¶
func (cc *CompCmdOpComplete) NthFlag(i int) (info FlagInfo, ok bool)
NthFlag implements FlagIter.
func (*CompCmdOpComplete) Setup ¶
func (cc *CompCmdOpComplete) Setup(defaultTimeout time.Duration) *Cmd
Setup returns the initialized *Cmd.
func (*CompCmdOpComplete) Task ¶
func (cc *CompCmdOpComplete) Task() *CompTask
Task returns the prepared CompTask.
type CompCmdPwsh ¶
type CompCmdPwsh CompCmdBash
CompCmdPwsh is a powershell completion command.
func (*CompCmdPwsh) Setup ¶
func (cc *CompCmdPwsh) Setup(opComplete *Cmd) *Cmd
Setup returns the prepared command.
opComplete is expected to be the return value of CompCmdOpComplete.Setup.
type CompCmdShells ¶
type CompCmdShells struct {
// contains filtered or unexported fields
}
CompCmdShells is wraps all supported shell completion commands:
- bash {,complete}
- zsh {,complete}
- pwsh {,complete}
To use it, the return value of (&CompCmdShells{}).Setup(...) should be a direct child to your application's root command.
type CompCmdZsh ¶
type CompCmdZsh CompCmdBash
CompCmdZsh is a zsh completion command.
func (*CompCmdZsh) Setup ¶
func (cc *CompCmdZsh) Setup(opComplete *Cmd) *Cmd
Setup returns the prepared command.
opComplete is expected to be the return value of CompCmdOpComplete.Setup().
type CompFmt ¶
type CompFmt interface { // Format writes one CompItem each line with shell specific character // escaping and formatting. Format(out io.Writer, finishedTask *CompTask) error }
CompFmt defines completion result formatter.
type CompFmtBash ¶
type CompFmtBash struct { // Cols is supposed to be the $COLUMNS in bash completion. Cols int // CompType is the type of completion: // // - '\t' (9) for normal completion // - '?' (63) for listing completions after successive tabs // - '!' (33) for listing alternatives on partial word completion // - '@' (64) to list completions if the word is not unmodified // - '%' (37) for menu completion // - '*' (42) for insert completion // // Refs: // - https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-COMP_005fTYPE CompType int }
CompFmtBash implements CompFmt for bash.
It produces two kinds of lines:
- ' <value>' (space prefixed) where <value> contains arguments to bash function _filedir.
- others (without space prefix), as bash-completion COMPREPLY element.
func (*CompFmtBash) EscapeSpaces ¶
type CompFmtPwsh ¶
type CompFmtPwsh struct { // Mods is the PowerShell completion mode, possible values are: // // - TabCompleteNext (default windows style - on each key press the next option is displayed) // - Complete (works like bash) // - MenuComplete (works like zsh) Mode string }
CompFmtPwsh implements CompFmt for powershell.
It produces two kinds of lines:
- `<value> ;<description>` (note the space and unescaped semi-colon) for creating CompletionResult items.
- `;<argument-spec>` (note the unescaped semi-colon prefix) for filesystem related completion.
func (*CompFmtPwsh) EscapeSpecialChars ¶
type CompFmtZsh ¶
type CompFmtZsh struct{}
CompFmtZsh implements CompFmt for zsh.
It produces two kinds of lines:
- `<value>:<description>` for zsh function _describe.
- `:<argument-spec>` (note the colon prefix) for zsh function _arguments, currently only used for filename and dirname completion.
func (CompFmtZsh) EscapeColons ¶
type CompItem ¶
type CompItem struct { // Value is the suggested text arg (e.g. foo, --bar). // // When Kind is one of [Files, Dirs], it is the glob pattern Value string // Description is the help text of the value. Description string // Kind marks the completion kind. Kind CompKind }
A CompItem is a completion suggestion.
type CompState ¶
type CompState uint32
CompState used by CompTask to manage completion values.
func (CompState) HasFlagNames ¶
func (CompState) HasFlagValues ¶
func (CompState) HasSubcmds ¶
func (CompState) OptionNosort ¶
func (CompState) OptionNospace ¶
type CompTask ¶
type CompTask struct { // ExecutablePath is the path to the executable which requested this // completion task. ExecutablePath string // Args are all args present on command-line, including args after the // one requested the completion. Args []string // At is the position of the arg to complete. // // when At == len(Args), the task is to suggest the next arg. // when 0 <= At <= len(Args)-1, the task is to complete the last partial arg. // when < len(Args)-1, the task is to complete previous partial arg. At int // ToComplete is the arg value to be compeleted. // // When completing a flag value, it is the value part of the arg, which // means if command-line input triggering the completion was // `--foo=s<tab>` and `foo` can be found in that context, then this field // will get `s`. ToComplete string // Route is the Cmd route up to the arg to complete. Route Route // PosArgs are all positional args found before the arg to complete. // // Depending on the position of the arg to complete, the Args field may // contain positional args, but this field can get nothing. PosArgs []string // DashArgs are all args found after the first dash but before the arg // to complete. // // If the arg to complete is before the dash, the Args may contain dash // but this field will get nothing. DashArgs []string // FlagMissingValue is the Flag right before the arg to complete and is // missing the value in arg to complete. FlagMissingValue Flag FlagValuePrefix string // contains filtered or unexported fields }
CompTask represents a completion tsk.
func (*CompTask) AddDefault ¶
AddDefault adds CompItems indicated by argument parsing (Init).
func (*CompTask) AddFlagNames ¶
func (tsk *CompTask) AddFlagNames(force bool, flags FlagIndexer, descr bool) (added int)
AddFlagNames adds flag names, it expects tsk.ToComplete either being an empty string or containing a flag name prefix (`-`, `--`).
If the argument `flags` is nil, use the target command's flags (tsk.Route).
func (*CompTask) AddFlagValues ¶
AddFlagValues adds matched values from the specified flag.
It retrieves completion suggestions by trying following methods in order:
- cast flag as CompAction.
- cast flag.Extra() as CompAction.
If addDefaults is true:
- add value returned by Flag.Default() if matched.
- deduce default value by flag State() unchange and HasValue() true.
func (*CompTask) AddMatched ¶
AddMatched filters CompItems and only adds those with tsk.ToComplete prefix.
func (*CompTask) AddSubcmds ¶
AddSubcmds adds sub-command names of cmd.
If the argument `cmd` is nil, use the last Cmd in tsk.Route.
Set descr to true to include description.
func (*CompTask) Done ¶
func (tsk *CompTask) Done()
Done marks this task as finished, no CompItem can be added without setting force=false.
func (*CompTask) Fail ¶
func (tsk *CompTask) Fail()
Fail marks this task as failed, and should not produce any completion at all.
func (*CompTask) Init ¶
func (tsk *CompTask) Init(root *Cmd, opts *CmdOptions, at int, args ...string)
Init initializes the CompTask with command-line options.
If pos is in range [0, len(args)), args[pos] is the arg to complete.
If the args slice is not empty, args[0] is expected to be the executable path.
func (*CompTask) RawToComplete ¶
RawToComplete returns the unprocessed arg value to complete.
func (*CompTask) SetDebugOutput ¶
SetDebugOutput sets the debug output used by the Debug method.
type DefaultReflectVPFactory ¶
type DefaultReflectVPFactory struct{}
DefaultReflectVPFactory is the ReflectVPFactory implementation referenced from comments of ReflectIndexer.
func (DefaultReflectVPFactory) GetVPReflectFor ¶
type DurationSlice ¶
predefined flag types for slice values from command line.
type DurationSliceV ¶
predefined flag types for slice values from command line.
type DurationSum ¶
predefined flag types for sumed scalar values from command line.
type DurationSumV ¶
predefined flag types for sumed scalar values from command line.
type ErrAmbiguousArgs ¶
ErrAmbiguousArgs caused by an arg (.Value) with hyphen (`-`) prefix, and the arg before it (.Name) is a flag name having implicit value but also accepts it as value.
func (*ErrAmbiguousArgs) Error ¶
func (err *ErrAmbiguousArgs) Error() string
type ErrCmdNotRunnable ¶
type ErrCmdNotRunnable struct {
Name string
}
ErrCmdNotRunnable
func (*ErrCmdNotRunnable) Error ¶
func (err *ErrCmdNotRunnable) Error() string
type ErrDuplicateFlag ¶
type ErrDuplicateFlag struct { // Name of the flag found duplicate. Name string }
ErrDuplicateFlag is the panic value caused by MapIndexer found duplicate flag registration.
func (*ErrDuplicateFlag) Error ¶
func (err *ErrDuplicateFlag) Error() string
Error implements error.
type ErrEmptyRoute ¶
type ErrEmptyRoute struct{}
func (ErrEmptyRoute) Error ¶
func (ErrEmptyRoute) Error() string
type ErrFlagSetAtMostOnce ¶
type ErrFlagSetAtMostOnce struct{}
ErrFlagSetAtMostOnce for flags marked once but appeared more than once.
func (ErrFlagSetAtMostOnce) Error ¶
func (ErrFlagSetAtMostOnce) Error() string
type ErrFlagUndefined ¶
type ErrFlagUndefined struct { // Name of the missing flag. Name string // At // // When >= 0, the error occurred during flag parsing and args[At] is the // arg containing the flag. // // When < 0, just a flag not defined. At int }
ErrFlagUndefined
func (*ErrFlagUndefined) Error ¶
func (err *ErrFlagUndefined) Error() string
Error implements error.
type ErrFlagValueInvalid ¶
type ErrFlagValueInvalid struct { // Name of the flag having invalid value. Name string // Value is the invalid value. Value string // NameAt is the arg index into the full arg list (`args`) // // args[NameAt] is the arg containing the flag name. NameAt int // ValueAt is the arg index into the full arg list (`args`) // // when >= 0, args[ValueAt] is the arg containing the flag value. // otherwise, the invalid value was implied by the flag. ValueAt int // Reason is the error caused this error. Reason error }
ErrFlagValueInvalid
func (*ErrFlagValueInvalid) Error ¶
func (err *ErrFlagValueInvalid) Error() string
type ErrFlagValueMissing ¶
type ErrFlagValueMissing struct { // Name is a single flag name without standard hyphen prefix. Name string // At is the arg index into the full arg list. At int }
ErrFlagValueMissing
func (*ErrFlagValueMissing) Error ¶
func (err *ErrFlagValueMissing) Error() string
Error implements error.
type ErrHelpHandled ¶
type ErrHelpHandled struct{}
ErrHelpHandled is used to notify caller the help request has been handled.
func (ErrHelpHandled) Error ¶
func (ErrHelpHandled) Error() string
type ErrHelpPending ¶
type ErrHelpPending struct { // HelpArg is the arg value that requested the help handling. HelpArg string // At is the HelpArg index into the full arg list. At int }
ErrHelpPending for help but no help handle func could be found.
func (*ErrHelpPending) Error ¶
func (err *ErrHelpPending) Error() string
type ErrInvalidValue ¶
type ErrInvalidValue struct { // Type is the type or format the Value supposed to be. Type string // Value is the actual bad value. Value string // Partial When set to true, means the Value contains a invalid part, // and that part is meant to be a Type value. Partial bool }
ErrInvalidValue
func (*ErrInvalidValue) Error ¶
func (v *ErrInvalidValue) Error() string
Error implements error.
- When v.Partial is true: "$v.Value contains invalid $v.Type value"
- When v.Partial is false: "$v.Value is not a valid %v.Type value"
type ErrShorthandOfExplicitFlagInMiddle ¶
type ErrShorthandOfExplicitFlagInMiddle struct { Shorthand string ShorthandCluster string Value string }
ErrShorthandOfExplicitFlagInMiddle caused by a cluster of flag shorthands with explicit value assigning (e.g. -abcdefg=foo), some shorthand in middle rather than the last one requires a explicit value.
func (*ErrShorthandOfExplicitFlagInMiddle) Error ¶
func (err *ErrShorthandOfExplicitFlagInMiddle) Error() string
type ErrTimeout ¶
type ErrTimeout struct{}
ErrTimeout
func (ErrTimeout) Error ¶
func (ErrTimeout) Error() string
type ErrUnsupportedType ¶
func (*ErrUnsupportedType) Error ¶
func (e *ErrUnsupportedType) Error() string
type Flag ¶
type Flag interface { // Type returns (typename, true) if there is type information for this // flag. Type() (string, bool) // ImplyValue returns the text implied by the existence of the flag name. // // return ("", false) to indicate the flag doesn't have implied value. ImplyValue() (string, bool) // Decode decodes a text argument to the flag value. Decode(opts *ParseOptions, name, arg string, set bool) error // Extra returns the user defined extra data. Extra() AnyMaybeCompActionAndHelperTerminal // FlagState returns the state of the flag. State() FlagState // HasValue returns true if calling PrintValue will write some // value. HasValue() bool // PrintValue writes the text representation of current value of // the flag. // // It MAY panic if HasValue returned false. PrintValue(out io.Writer) (int, error) // Usage returns the brief usage of the flag. Usage() string }
Flag defines the interface of an entry used by FlagIndexer and ParseFlag.
NOTE: In this package, a Flag's default value is provided by the FlagInfo and will only be assign to Flags inside Cmd.Exec.
type FlagBase ¶
type FlagBase[T any, P VP[*T]] struct { // BriefUsage is the help text for terminal user. BriefUsage string // Ext is the extra custom data for this flag. Ext AnyMaybeCompActionAndHelperTerminal // Value points to the actual variable to set. Value *T VP P // State_ of the flag. State_ FlagState }
FlagBase holds a pointer to the actual value.
func (*FlagBase[T, P]) Decode ¶
func (f *FlagBase[T, P]) Decode(opts *ParseOptions, name, arg string, set bool) error
func (*FlagBase[T, P]) ImplyValue ¶
type FlagBaseV ¶
type FlagBaseV[T any, P VP[*T]] struct { // BriefUsage is the help text for terminal user. BriefUsage string // Ext is the extra custom data for this flag. Ext AnyMaybeCompActionAndHelperTerminal // State_ of the flag. State_ FlagState // Value of the flag. Value T VP P }
FlagBaseV is FlagBase but with value embedded.
func (*FlagBaseV[T, P]) Decode ¶
func (f *FlagBaseV[T, P]) Decode(opts *ParseOptions, name, arg string, set bool) error
func (*FlagBaseV[T, P]) ImplyValue ¶
func (*FlagBaseV[T, P]) PrintValue ¶
type FlagEmptyV ¶
FlagEmptyV is a flag without value.
func (*FlagEmptyV) Decode ¶
func (f *FlagEmptyV) Decode(opts *ParseOptions, name, arg string, set bool) error
func (*FlagEmptyV) Extra ¶
func (f *FlagEmptyV) Extra() any
func (*FlagEmptyV) HasValue ¶
func (f *FlagEmptyV) HasValue() bool
func (*FlagEmptyV) ImplyValue ¶
func (f *FlagEmptyV) ImplyValue() (string, bool)
func (*FlagEmptyV) PrintValue ¶
func (f *FlagEmptyV) PrintValue(io.Writer) (int, error)
func (*FlagEmptyV) State ¶
func (f *FlagEmptyV) State() FlagState
func (*FlagEmptyV) Type ¶
func (f *FlagEmptyV) Type() (string, bool)
func (*FlagEmptyV) Usage ¶
func (f *FlagEmptyV) Usage() string
type FlagFinder ¶
type FlagFinder interface { // FindFlag searches flags known to this FlagFinder by name. // // The name can be either a full flag name or a flag shorthand, and // doesn't contain the POSIX & GNU flag prefix (`-` and `--`). FindFlag(name string) (Flag, bool) }
FlagFinder
type FlagFinderMaybeIter ¶
type FlagFinderMaybeIter = FlagFinder
FlagFinderMaybeIter is an alias of FlagFinder but indicates the implementation may have additional FlagIter support.
type FlagHelp ¶
type FlagHelp struct { // Experimental explains why the flag is Experimental. // // Only use this field to note the reason of being experimental, and // DO NOT include prefix like `EXPERIMENTAL: ` Experimental string // Deprecation is the deprecation message of the flag. // // Only use this field to note the reason of deprecation, and // DO NOT include prefix like `DEPRECATED: ` Deprecation string // Changelog may contain upgrade notice of the flag. // // DO NOT include prefix like `CHANGELOG: ` Changelog string // Completion is the completion action to be called to add suggestions. Completion CompAction // Extra custom data. Extra any }
FlagHelp defines commonly used flag metadata
Hint: use .Extra of a flag to hold FlagHelp for documentation purpose.
func (*FlagHelp) HelplnCmdTerminal ¶
func (*FlagHelp) HelplnFlagTerminal ¶
type FlagIndexer ¶
type FlagIndexer interface { FlagFinder FlagIter }
FlagIndexer is the combination of FlagFinder and FlagIter.
type FlagInfo ¶
type FlagInfo struct { // Name is the long flag name (the long one). Name string // Shorthand is the flag shorthand. Shorthand string // DefaultValue is the default value used for the flag. // // Please use following format to provide non-scalar default value: // '[' + entry1 + ', ' + entry2 ... ']' // // NOTE: For non-scalar values, when default value is being assigned // by Cmd.Exec, it checks prefix '[' and suffix ']', and splits // elements by cutting around ', '. DefaultValue string // State is the current state of the flag. State FlagState }
FlagInfo is a pack of the flag name, shorthand, default value and current state.
type FlagIter ¶
type FlagIter interface { // NthFlag returns the i-th flag's info this iterator can find. // // The bool return value indicates whether there is i-th flag, on // returning false, call with any value greater than i should return // false as well. NthFlag(i int) (FlagInfo, bool) }
FlagIter
type FlagLevel ¶
type FlagLevel interface { // TrimAllLevelPrefixes tirms all prefixes belonging to each level. TrimAllLevelPrefixes(name string) string // GetFullFlagName adds all prefixes to name. GetFullFlagName(name string) string }
FlagLevel
type FlagReflect ¶
type FlagReflect struct { VP VP[*reflect.Value] Value reflect.Value BriefUsage string DefaultValue string Comp []string State_ FlagState }
FlagReflect
It is used internally by the ReflectIndexer.
func (*FlagReflect) Decode ¶
func (f *FlagReflect) Decode(opts *ParseOptions, name, arg string, set bool) error
func (*FlagReflect) Default ¶
func (f *FlagReflect) Default() string
func (*FlagReflect) Extra ¶
func (f *FlagReflect) Extra() any
func (*FlagReflect) HasValue ¶
func (f *FlagReflect) HasValue() bool
func (*FlagReflect) ImplyValue ¶
func (f *FlagReflect) ImplyValue() (string, bool)
func (*FlagReflect) PrintValue ¶
func (f *FlagReflect) PrintValue(out io.Writer) (int, error)
func (*FlagReflect) State ¶
func (f *FlagReflect) State() FlagState
func (*FlagReflect) Suggest ¶
func (f *FlagReflect) Suggest(tsk *CompTask) (added int, _ CompState)
Suggest implements CompAction.
func (*FlagReflect) Type ¶
func (f *FlagReflect) Type() (string, bool)
func (*FlagReflect) Usage ¶
func (f *FlagReflect) Usage() string
type FlagState ¶
type FlagState uint32
FlagState contains bits representing a Flag's state.
const ( // FlagStateValueChanged marks the value of the flag is changed. // // It SHOULD only be set inside method Flag.Decode when set is true. FlagStateValueChanged FlagState = 1 << iota // FlagStateHidden marks the flag hidden. FlagStateHidden // FlagStateSetAtMostOnce marks the flag should only enjoy successful // decoding with set=true at most once. FlagStateSetAtMostOnce )
func (FlagState) SetAtMostOnce ¶
func (FlagState) ValueChanged ¶
type FlagViolation ¶
type FlagViolation Violation
A FlagViolation represents a rule violation caused by flag.
func (*FlagViolation) Error ¶
func (err *FlagViolation) Error() string
type Float32Slice ¶
predefined flag types for slice values from command line.
type Float32SliceV ¶
predefined flag types for slice values from command line.
type Float32Sum ¶
predefined flag types for sumed scalar values from command line.
type Float32SumV ¶
predefined flag types for sumed scalar values from command line.
type Float64Slice ¶
predefined flag types for slice values from command line.
type Float64SliceV ¶
predefined flag types for slice values from command line.
type Float64Sum ¶
predefined flag types for sumed scalar values from command line.
type Float64SumV ¶
predefined flag types for sumed scalar values from command line.
type FuncIndexer ¶
FuncIndexer wraps a function as FlagIndexer.
when index < 0, act as FlagFinder, otherwise act as FlagIter.
func (FuncIndexer) FindFlag ¶
func (fn FuncIndexer) FindFlag(name string) (Flag, bool)
FindFlag implements FlagFinder.
type HelpHandleFunc ¶
type HelpHandleFunc = func( opts *CmdOptions, route Route, args []string, helpArgAt int, ) error
HelpHandleFunc for handling help requests.
when helpArgAt < 0, this function was called as the fallback of ArgErrorHandleFunc, and the argErr is discarded.
when helpArgAt >= 0, args[helpArgAt] is the arg initiated the help request, in this case return nil error will be replaced with ErrHelpRequestHandled{}.
type HelperTerminal ¶
type HelperTerminal interface { // HelplnCmdTerminal writes help messages for the target command // with a newline in the end. HelplnCmdTerminal(out io.Writer, route Route, linePrefix string) (int, error) // HelplnFlagTerminal writes help meesages for the flag with a newline // in the end. HelplnFlagTerminal( out io.Writer, route Route, linePrefix string, indent int, flag FlagInfo, groupHasShorthand bool, ) (int, error) }
HelperTerminal writes help messages for a terminal user.
type Inspector ¶
type Inspector interface { // CheckFlagValueChanged returns ture if the flag's value has been changed. CheckFlagValueChanged(key string) bool }
An Inspector is an external verifier used to check rule enforcement.
type Int16Slice ¶
predefined flag types for slice values from command line.
type Int16SliceV ¶
predefined flag types for slice values from command line.
type Int32Slice ¶
predefined flag types for slice values from command line.
type Int32SliceV ¶
predefined flag types for slice values from command line.
type Int64Slice ¶
predefined flag types for slice values from command line.
type Int64SliceV ¶
predefined flag types for slice values from command line.
type Int8SliceV ¶
predefined flag types for slice values from command line.
type LevelIndexer ¶
type LevelIndexer struct { // Up points to the up level, if any. Up FlagLevel // Prefix is the prefix to identify this level. // // Should not be empty for non-root level. Prefix string // Flags Flags FlagFinderMaybeIter // contains filtered or unexported fields }
LevelIndexer is a FlagFinder wrapper to build multi-level flag hierarchy.
func (*LevelIndexer) FindFlag ¶
func (l *LevelIndexer) FindFlag(name string) (Flag, bool)
FindFlag implements FlagFinder.
func (*LevelIndexer) GetFullFlagName ¶
func (l *LevelIndexer) GetFullFlagName(name string) string
GetFullFlagName implements FlagLevel.
func (*LevelIndexer) NthFlag ¶
func (l *LevelIndexer) NthFlag(i int) (info FlagInfo, ok bool)
NthFlag implements FlagIter.
func (*LevelIndexer) TrimAllLevelPrefixes ¶
func (l *LevelIndexer) TrimAllLevelPrefixes(name string) string
TrimAllLevelPrefixes implements FlagLevel.
type MapIndexer ¶
type MapIndexer struct {
// contains filtered or unexported fields
}
MapIndexer implements FlagIndexer using built-in maps.
func (*MapIndexer) Add ¶
func (m *MapIndexer) Add(flag Flag, names ...string) *MapIndexer
Add adds a flag with its names.
It panics when name is empty or there is flag with same name shorthand.
func (*MapIndexer) AddWithDefaultValue ¶
func (m *MapIndexer) AddWithDefaultValue(defaultValue string, flag Flag, names ...string) *MapIndexer
AddWithDefaultValue is Add but provides default value to the flag.
func (*MapIndexer) FindFlag ¶
func (m *MapIndexer) FindFlag(name string) (Flag, bool)
FindFlag implements FlagFinder.
type MapIntBool ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntBoolSlice ¶
type MapIntBoolSlice = FlagBase[map[int][]bool, VPMap[int, []bool, VPInt[int], VPSlice[bool, VPBool[bool]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntBoolSliceV ¶
type MapIntBoolSliceV = FlagBase[map[int][]bool, VPMap[int, []bool, VPInt[int], VPSlice[bool, VPBool[bool]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntBoolV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntDuration ¶
type MapIntDuration = FlagBase[map[int]time.Duration, VPMap[int, time.Duration, VPInt[int], VPDuration[time.Duration]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntDurationSlice ¶
type MapIntDurationSlice = FlagBase[map[int][]time.Duration, VPMap[int, []time.Duration, VPInt[int], VPSlice[time.Duration, VPDuration[time.Duration]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntDurationSliceV ¶
type MapIntDurationSliceV = FlagBase[map[int][]time.Duration, VPMap[int, []time.Duration, VPInt[int], VPSlice[time.Duration, VPDuration[time.Duration]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntDurationSum ¶
type MapIntDurationSum = FlagBase[map[int]time.Duration, VPMap[int, time.Duration, VPInt[int], VPSum[time.Duration, VPDuration[time.Duration]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntDurationSumV ¶
type MapIntDurationSumV = FlagBase[map[int]time.Duration, VPMap[int, time.Duration, VPInt[int], VPSum[time.Duration, VPDuration[time.Duration]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntDurationV ¶
type MapIntDurationV = FlagBase[map[int]time.Duration, VPMap[int, time.Duration, VPInt[int], VPDuration[time.Duration]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat32 ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat32Slice ¶
type MapIntFloat32Slice = FlagBase[map[int][]float32, VPMap[int, []float32, VPInt[int], VPSlice[float32, VPFloat[float32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat32SliceV ¶
type MapIntFloat32SliceV = FlagBase[map[int][]float32, VPMap[int, []float32, VPInt[int], VPSlice[float32, VPFloat[float32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat32Sum ¶
type MapIntFloat32Sum = FlagBase[map[int]float32, VPMap[int, float32, VPInt[int], VPSum[float32, VPFloat[float32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat32SumV ¶
type MapIntFloat32SumV = FlagBase[map[int]float32, VPMap[int, float32, VPInt[int], VPSum[float32, VPFloat[float32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat32V ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat64 ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat64Slice ¶
type MapIntFloat64Slice = FlagBase[map[int][]float64, VPMap[int, []float64, VPInt[int], VPSlice[float64, VPFloat[float64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat64SliceV ¶
type MapIntFloat64SliceV = FlagBase[map[int][]float64, VPMap[int, []float64, VPInt[int], VPSlice[float64, VPFloat[float64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat64Sum ¶
type MapIntFloat64Sum = FlagBase[map[int]float64, VPMap[int, float64, VPInt[int], VPSum[float64, VPFloat[float64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat64SumV ¶
type MapIntFloat64SumV = FlagBase[map[int]float64, VPMap[int, float64, VPInt[int], VPSum[float64, VPFloat[float64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntFloat64V ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt16 ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt16Slice ¶
type MapIntInt16Slice = FlagBase[map[int][]int16, VPMap[int, []int16, VPInt[int], VPSlice[int16, VPInt[int16]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt16SliceV ¶
type MapIntInt16SliceV = FlagBase[map[int][]int16, VPMap[int, []int16, VPInt[int], VPSlice[int16, VPInt[int16]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt16Sum ¶
type MapIntInt16Sum = FlagBase[map[int]int16, VPMap[int, int16, VPInt[int], VPSum[int16, VPInt[int16]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt16SumV ¶
type MapIntInt16SumV = FlagBase[map[int]int16, VPMap[int, int16, VPInt[int], VPSum[int16, VPInt[int16]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt16V ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt32 ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt32Slice ¶
type MapIntInt32Slice = FlagBase[map[int][]int32, VPMap[int, []int32, VPInt[int], VPSlice[int32, VPInt[int32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt32SliceV ¶
type MapIntInt32SliceV = FlagBase[map[int][]int32, VPMap[int, []int32, VPInt[int], VPSlice[int32, VPInt[int32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt32Sum ¶
type MapIntInt32Sum = FlagBase[map[int]int32, VPMap[int, int32, VPInt[int], VPSum[int32, VPInt[int32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt32SumV ¶
type MapIntInt32SumV = FlagBase[map[int]int32, VPMap[int, int32, VPInt[int], VPSum[int32, VPInt[int32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt32V ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt64 ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt64Slice ¶
type MapIntInt64Slice = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPInt[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt64SliceV ¶
type MapIntInt64SliceV = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPInt[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt64Sum ¶
type MapIntInt64Sum = FlagBase[map[int]int64, VPMap[int, int64, VPInt[int], VPSum[int64, VPInt[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt64SumV ¶
type MapIntInt64SumV = FlagBase[map[int]int64, VPMap[int, int64, VPInt[int], VPSum[int64, VPInt[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt64V ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt8 ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt8Slice ¶
type MapIntInt8Slice = FlagBase[map[int][]int8, VPMap[int, []int8, VPInt[int], VPSlice[int8, VPInt[int8]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt8SliceV ¶
type MapIntInt8SliceV = FlagBase[map[int][]int8, VPMap[int, []int8, VPInt[int], VPSlice[int8, VPInt[int8]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt8Sum ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt8SumV ¶
type MapIntInt8SumV = FlagBase[map[int]int8, VPMap[int, int8, VPInt[int], VPSum[int8, VPInt[int8]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntInt8V ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntIntSlice ¶
type MapIntIntSlice = FlagBase[map[int][]int, VPMap[int, []int, VPInt[int], VPSlice[int, VPInt[int]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntIntSliceV ¶
type MapIntIntSliceV = FlagBase[map[int][]int, VPMap[int, []int, VPInt[int], VPSlice[int, VPInt[int]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntIntSum ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntIntSumV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntIntV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntRegexp ¶
type MapIntRegexp = FlagBase[map[int]*regexp.Regexp, VPMap[int, *regexp.Regexp, VPInt[int], VPPointer[regexp.Regexp, VPRegexp[regexp.Regexp]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntRegexpNocase ¶
type MapIntRegexpNocase = FlagBase[map[int]*regexp.Regexp, VPMap[int, *regexp.Regexp, VPInt[int], VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntRegexpNocaseSlice ¶
type MapIntRegexpNocaseSlice = FlagBase[map[int][]*regexp.Regexp, VPMap[int, []*regexp.Regexp, VPInt[int], VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntRegexpNocaseSliceV ¶
type MapIntRegexpNocaseSliceV = FlagBase[map[int][]*regexp.Regexp, VPMap[int, []*regexp.Regexp, VPInt[int], VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntRegexpNocaseV ¶
type MapIntRegexpNocaseV = FlagBase[map[int]*regexp.Regexp, VPMap[int, *regexp.Regexp, VPInt[int], VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntRegexpSlice ¶
type MapIntRegexpSlice = FlagBase[map[int][]*regexp.Regexp, VPMap[int, []*regexp.Regexp, VPInt[int], VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexp[regexp.Regexp]]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntRegexpSliceV ¶
type MapIntRegexpSliceV = FlagBase[map[int][]*regexp.Regexp, VPMap[int, []*regexp.Regexp, VPInt[int], VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexp[regexp.Regexp]]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntRegexpV ¶
type MapIntRegexpV = FlagBase[map[int]*regexp.Regexp, VPMap[int, *regexp.Regexp, VPInt[int], VPPointer[regexp.Regexp, VPRegexp[regexp.Regexp]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntSize ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntSizeSlice ¶
type MapIntSizeSlice = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPSize[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntSizeSliceV ¶
type MapIntSizeSliceV = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPSize[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntSizeSum ¶
type MapIntSizeSum = FlagBase[map[int]int64, VPMap[int, int64, VPInt[int], VPSum[int64, VPSize[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntSizeSumV ¶
type MapIntSizeSumV = FlagBase[map[int]int64, VPMap[int, int64, VPInt[int], VPSum[int64, VPSize[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntSizeV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntString ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntStringSlice ¶
type MapIntStringSlice = FlagBase[map[int][]string, VPMap[int, []string, VPInt[int], VPSlice[string, VPString[string]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntStringSliceV ¶
type MapIntStringSliceV = FlagBase[map[int][]string, VPMap[int, []string, VPInt[int], VPSlice[string, VPString[string]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntStringV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntTime ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntTimeSlice ¶
type MapIntTimeSlice = FlagBase[map[int][]time.Time, VPMap[int, []time.Time, VPInt[int], VPSlice[time.Time, VPTime[time.Time]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntTimeSliceV ¶
type MapIntTimeSliceV = FlagBase[map[int][]time.Time, VPMap[int, []time.Time, VPInt[int], VPSlice[time.Time, VPTime[time.Time]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntTimeV ¶
type MapIntTimeV = FlagBase[map[int]time.Time, VPMap[int, time.Time, VPInt[int], VPTime[time.Time]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint16 ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint16Slice ¶
type MapIntUint16Slice = FlagBase[map[int][]uint16, VPMap[int, []uint16, VPInt[int], VPSlice[uint16, VPUint[uint16]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint16SliceV ¶
type MapIntUint16SliceV = FlagBase[map[int][]uint16, VPMap[int, []uint16, VPInt[int], VPSlice[uint16, VPUint[uint16]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint16Sum ¶
type MapIntUint16Sum = FlagBase[map[int]uint16, VPMap[int, uint16, VPInt[int], VPSum[uint16, VPUint[uint16]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint16SumV ¶
type MapIntUint16SumV = FlagBase[map[int]uint16, VPMap[int, uint16, VPInt[int], VPSum[uint16, VPUint[uint16]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint16V ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint32 ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint32Slice ¶
type MapIntUint32Slice = FlagBase[map[int][]uint32, VPMap[int, []uint32, VPInt[int], VPSlice[uint32, VPUint[uint32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint32SliceV ¶
type MapIntUint32SliceV = FlagBase[map[int][]uint32, VPMap[int, []uint32, VPInt[int], VPSlice[uint32, VPUint[uint32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint32Sum ¶
type MapIntUint32Sum = FlagBase[map[int]uint32, VPMap[int, uint32, VPInt[int], VPSum[uint32, VPUint[uint32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint32SumV ¶
type MapIntUint32SumV = FlagBase[map[int]uint32, VPMap[int, uint32, VPInt[int], VPSum[uint32, VPUint[uint32]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint32V ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint64 ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint64Slice ¶
type MapIntUint64Slice = FlagBase[map[int][]uint64, VPMap[int, []uint64, VPInt[int], VPSlice[uint64, VPUint[uint64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint64SliceV ¶
type MapIntUint64SliceV = FlagBase[map[int][]uint64, VPMap[int, []uint64, VPInt[int], VPSlice[uint64, VPUint[uint64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint64Sum ¶
type MapIntUint64Sum = FlagBase[map[int]uint64, VPMap[int, uint64, VPInt[int], VPSum[uint64, VPUint[uint64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint64SumV ¶
type MapIntUint64SumV = FlagBase[map[int]uint64, VPMap[int, uint64, VPInt[int], VPSum[uint64, VPUint[uint64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint64V ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint8 ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint8Slice ¶
type MapIntUint8Slice = FlagBase[map[int][]uint8, VPMap[int, []uint8, VPInt[int], VPSlice[uint8, VPUint[uint8]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint8SliceV ¶
type MapIntUint8SliceV = FlagBase[map[int][]uint8, VPMap[int, []uint8, VPInt[int], VPSlice[uint8, VPUint[uint8]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint8Sum ¶
type MapIntUint8Sum = FlagBase[map[int]uint8, VPMap[int, uint8, VPInt[int], VPSum[uint8, VPUint[uint8]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint8SumV ¶
type MapIntUint8SumV = FlagBase[map[int]uint8, VPMap[int, uint8, VPInt[int], VPSum[uint8, VPUint[uint8]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUint8V ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintSlice ¶
type MapIntUintSlice = FlagBase[map[int][]uint, VPMap[int, []uint, VPInt[int], VPSlice[uint, VPUint[uint]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintSliceV ¶
type MapIntUintSliceV = FlagBase[map[int][]uint, VPMap[int, []uint, VPInt[int], VPSlice[uint, VPUint[uint]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintSum ¶
type MapIntUintSum = FlagBase[map[int]uint, VPMap[int, uint, VPInt[int], VPSum[uint, VPUint[uint]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintSumV ¶
type MapIntUintSumV = FlagBase[map[int]uint, VPMap[int, uint, VPInt[int], VPSum[uint, VPUint[uint]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintptr ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintptrSlice ¶
type MapIntUintptrSlice = FlagBase[map[int][]uintptr, VPMap[int, []uintptr, VPInt[int], VPSlice[uintptr, VPUint[uintptr]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintptrSliceV ¶
type MapIntUintptrSliceV = FlagBase[map[int][]uintptr, VPMap[int, []uintptr, VPInt[int], VPSlice[uintptr, VPUint[uintptr]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintptrSum ¶
type MapIntUintptrSum = FlagBase[map[int]uintptr, VPMap[int, uintptr, VPInt[int], VPSum[uintptr, VPUint[uintptr]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintptrSumV ¶
type MapIntUintptrSumV = FlagBase[map[int]uintptr, VPMap[int, uintptr, VPInt[int], VPSum[uintptr, VPUint[uintptr]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUintptrV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixMicro ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixMicroSlice ¶
type MapIntUnixMicroSlice = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPUnixMicro[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixMicroSliceV ¶
type MapIntUnixMicroSliceV = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPUnixMicro[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixMicroV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixMilli ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixMilliSlice ¶
type MapIntUnixMilliSlice = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPUnixMilli[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixMilliSliceV ¶
type MapIntUnixMilliSliceV = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPUnixMilli[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixMilliV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixNano ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixNanoSlice ¶
type MapIntUnixNanoSlice = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPUnixNano[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixNanoSliceV ¶
type MapIntUnixNanoSliceV = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPUnixNano[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixNanoV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixSec ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixSecSlice ¶
type MapIntUnixSecSlice = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPUnixSec[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixSecSliceV ¶
type MapIntUnixSecSliceV = FlagBase[map[int][]int64, VPMap[int, []int64, VPInt[int], VPSlice[int64, VPUnixSec[int64]]]]
predefined flag types for "<int>=<scalar>" from command line.
type MapIntUnixSecV ¶
predefined flag types for "<int>=<scalar>" from command line.
type MapStringBool ¶
predefined flag types for "<string>=<scalar>" from command line.
type MapStringBoolSlice ¶
type MapStringBoolSlice = FlagBase[map[string][]bool, VPMap[string, []bool, VPString[string], VPSlice[bool, VPBool[bool]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringBoolSliceV ¶
type MapStringBoolSliceV = FlagBaseV[map[string][]bool, VPMap[string, []bool, VPString[string], VPSlice[bool, VPBool[bool]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringBoolV ¶
type MapStringBoolV = FlagBaseV[map[string]bool, VPMap[string, bool, VPString[string], VPBool[bool]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringDuration ¶
type MapStringDuration = FlagBase[map[string]time.Duration, VPMap[string, time.Duration, VPString[string], VPDuration[time.Duration]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringDurationSlice ¶
type MapStringDurationSlice = FlagBase[map[string][]time.Duration, VPMap[string, []time.Duration, VPString[string], VPSlice[time.Duration, VPDuration[time.Duration]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringDurationSliceV ¶
type MapStringDurationSliceV = FlagBaseV[map[string][]time.Duration, VPMap[string, []time.Duration, VPString[string], VPSlice[time.Duration, VPDuration[time.Duration]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringDurationSum ¶
type MapStringDurationSum = FlagBase[map[string]time.Duration, VPMap[string, time.Duration, VPString[string], VPSum[time.Duration, VPDuration[time.Duration]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringDurationSumV ¶
type MapStringDurationSumV = FlagBaseV[map[string]time.Duration, VPMap[string, time.Duration, VPString[string], VPSum[time.Duration, VPDuration[time.Duration]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringDurationV ¶
type MapStringDurationV = FlagBaseV[map[string]time.Duration, VPMap[string, time.Duration, VPString[string], VPDuration[time.Duration]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat32 ¶
type MapStringFloat32 = FlagBase[map[string]float32, VPMap[string, float32, VPString[string], VPFloat[float32]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat32Slice ¶
type MapStringFloat32Slice = FlagBase[map[string][]float32, VPMap[string, []float32, VPString[string], VPSlice[float32, VPFloat[float32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat32SliceV ¶
type MapStringFloat32SliceV = FlagBaseV[map[string][]float32, VPMap[string, []float32, VPString[string], VPSlice[float32, VPFloat[float32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat32Sum ¶
type MapStringFloat32Sum = FlagBase[map[string]float32, VPMap[string, float32, VPString[string], VPSum[float32, VPFloat[float32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat32SumV ¶
type MapStringFloat32SumV = FlagBaseV[map[string]float32, VPMap[string, float32, VPString[string], VPSum[float32, VPFloat[float32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat32V ¶
type MapStringFloat32V = FlagBaseV[map[string]float32, VPMap[string, float32, VPString[string], VPFloat[float32]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat64 ¶
type MapStringFloat64 = FlagBase[map[string]float64, VPMap[string, float64, VPString[string], VPFloat[float64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat64Slice ¶
type MapStringFloat64Slice = FlagBase[map[string][]float64, VPMap[string, []float64, VPString[string], VPSlice[float64, VPFloat[float64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat64SliceV ¶
type MapStringFloat64SliceV = FlagBaseV[map[string][]float64, VPMap[string, []float64, VPString[string], VPSlice[float64, VPFloat[float64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat64Sum ¶
type MapStringFloat64Sum = FlagBase[map[string]float64, VPMap[string, float64, VPString[string], VPSum[float64, VPFloat[float64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat64SumV ¶
type MapStringFloat64SumV = FlagBaseV[map[string]float64, VPMap[string, float64, VPString[string], VPSum[float64, VPFloat[float64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringFloat64V ¶
type MapStringFloat64V = FlagBaseV[map[string]float64, VPMap[string, float64, VPString[string], VPFloat[float64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt ¶
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt16 ¶
type MapStringInt16 = FlagBase[map[string]int16, VPMap[string, int16, VPString[string], VPInt[int16]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt16Slice ¶
type MapStringInt16Slice = FlagBase[map[string][]int16, VPMap[string, []int16, VPString[string], VPSlice[int16, VPInt[int16]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt16SliceV ¶
type MapStringInt16SliceV = FlagBaseV[map[string][]int16, VPMap[string, []int16, VPString[string], VPSlice[int16, VPInt[int16]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt16Sum ¶
type MapStringInt16Sum = FlagBase[map[string]int16, VPMap[string, int16, VPString[string], VPSum[int16, VPInt[int16]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt16SumV ¶
type MapStringInt16SumV = FlagBaseV[map[string]int16, VPMap[string, int16, VPString[string], VPSum[int16, VPInt[int16]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt16V ¶
type MapStringInt16V = FlagBaseV[map[string]int16, VPMap[string, int16, VPString[string], VPInt[int16]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt32 ¶
type MapStringInt32 = FlagBase[map[string]int32, VPMap[string, int32, VPString[string], VPInt[int32]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt32Slice ¶
type MapStringInt32Slice = FlagBase[map[string][]int32, VPMap[string, []int32, VPString[string], VPSlice[int32, VPInt[int32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt32SliceV ¶
type MapStringInt32SliceV = FlagBaseV[map[string][]int32, VPMap[string, []int32, VPString[string], VPSlice[int32, VPInt[int32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt32Sum ¶
type MapStringInt32Sum = FlagBase[map[string]int32, VPMap[string, int32, VPString[string], VPSum[int32, VPInt[int32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt32SumV ¶
type MapStringInt32SumV = FlagBaseV[map[string]int32, VPMap[string, int32, VPString[string], VPSum[int32, VPInt[int32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt32V ¶
type MapStringInt32V = FlagBaseV[map[string]int32, VPMap[string, int32, VPString[string], VPInt[int32]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt64 ¶
type MapStringInt64 = FlagBase[map[string]int64, VPMap[string, int64, VPString[string], VPInt[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt64Slice ¶
type MapStringInt64Slice = FlagBase[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPInt[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt64SliceV ¶
type MapStringInt64SliceV = FlagBaseV[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPInt[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt64Sum ¶
type MapStringInt64Sum = FlagBase[map[string]int64, VPMap[string, int64, VPString[string], VPSum[int64, VPInt[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt64SumV ¶
type MapStringInt64SumV = FlagBaseV[map[string]int64, VPMap[string, int64, VPString[string], VPSum[int64, VPInt[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt64V ¶
type MapStringInt64V = FlagBaseV[map[string]int64, VPMap[string, int64, VPString[string], VPInt[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt8 ¶
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt8Slice ¶
type MapStringInt8Slice = FlagBase[map[string][]int8, VPMap[string, []int8, VPString[string], VPSlice[int8, VPInt[int8]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt8SliceV ¶
type MapStringInt8SliceV = FlagBaseV[map[string][]int8, VPMap[string, []int8, VPString[string], VPSlice[int8, VPInt[int8]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt8Sum ¶
type MapStringInt8Sum = FlagBase[map[string]int8, VPMap[string, int8, VPString[string], VPSum[int8, VPInt[int8]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt8SumV ¶
type MapStringInt8SumV = FlagBaseV[map[string]int8, VPMap[string, int8, VPString[string], VPSum[int8, VPInt[int8]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringInt8V ¶
type MapStringInt8V = FlagBaseV[map[string]int8, VPMap[string, int8, VPString[string], VPInt[int8]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringIntSlice ¶
type MapStringIntSlice = FlagBase[map[string][]int, VPMap[string, []int, VPString[string], VPSlice[int, VPInt[int]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringIntSliceV ¶
type MapStringIntSliceV = FlagBaseV[map[string][]int, VPMap[string, []int, VPString[string], VPSlice[int, VPInt[int]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringIntSum ¶
type MapStringIntSum = FlagBase[map[string]int, VPMap[string, int, VPString[string], VPSum[int, VPInt[int]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringIntSumV ¶
type MapStringIntSumV = FlagBaseV[map[string]int, VPMap[string, int, VPString[string], VPSum[int, VPInt[int]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringIntV ¶
predefined flag types for "<string>=<scalar>" from command line.
type MapStringRegexp ¶
type MapStringRegexp = FlagBase[map[string]*regexp.Regexp, VPMap[string, *regexp.Regexp, VPString[string], VPPointer[regexp.Regexp, VPRegexp[regexp.Regexp]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringRegexpNocase ¶
type MapStringRegexpNocase = FlagBase[map[string]*regexp.Regexp, VPMap[string, *regexp.Regexp, VPString[string], VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringRegexpNocaseSlice ¶
type MapStringRegexpNocaseSlice = FlagBase[map[string][]*regexp.Regexp, VPMap[string, []*regexp.Regexp, VPString[string], VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringRegexpNocaseSliceV ¶
type MapStringRegexpNocaseSliceV = FlagBaseV[map[string][]*regexp.Regexp, VPMap[string, []*regexp.Regexp, VPString[string], VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringRegexpNocaseV ¶
type MapStringRegexpNocaseV = FlagBaseV[map[string]*regexp.Regexp, VPMap[string, *regexp.Regexp, VPString[string], VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringRegexpSlice ¶
type MapStringRegexpSlice = FlagBase[map[string][]*regexp.Regexp, VPMap[string, []*regexp.Regexp, VPString[string], VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexp[regexp.Regexp]]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringRegexpSliceV ¶
type MapStringRegexpSliceV = FlagBaseV[map[string][]*regexp.Regexp, VPMap[string, []*regexp.Regexp, VPString[string], VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexp[regexp.Regexp]]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringRegexpV ¶
type MapStringRegexpV = FlagBaseV[map[string]*regexp.Regexp, VPMap[string, *regexp.Regexp, VPString[string], VPPointer[regexp.Regexp, VPRegexp[regexp.Regexp]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringSize ¶
type MapStringSize = FlagBase[map[string]int64, VPMap[string, int64, VPString[string], VPSize[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringSizeSlice ¶
type MapStringSizeSlice = FlagBase[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPSize[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringSizeSliceV ¶
type MapStringSizeSliceV = FlagBaseV[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPSize[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringSizeSum ¶
type MapStringSizeSum = FlagBase[map[string]int64, VPMap[string, int64, VPString[string], VPSum[int64, VPSize[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringSizeSumV ¶
type MapStringSizeSumV = FlagBaseV[map[string]int64, VPMap[string, int64, VPString[string], VPSum[int64, VPSize[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringSizeV ¶
type MapStringSizeV = FlagBaseV[map[string]int64, VPMap[string, int64, VPString[string], VPSize[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringString ¶
type MapStringString = FlagBase[map[string]string, VPMap[string, string, VPString[string], VPString[string]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringStringSlice ¶
type MapStringStringSlice = FlagBase[map[string][]string, VPMap[string, []string, VPString[string], VPSlice[string, VPString[string]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringStringSliceV ¶
type MapStringStringSliceV = FlagBaseV[map[string][]string, VPMap[string, []string, VPString[string], VPSlice[string, VPString[string]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringStringV ¶
type MapStringStringV = FlagBaseV[map[string]string, VPMap[string, string, VPString[string], VPString[string]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringTime ¶
type MapStringTime = FlagBase[map[string]time.Time, VPMap[string, time.Time, VPString[string], VPTime[time.Time]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringTimeSlice ¶
type MapStringTimeSlice = FlagBase[map[string][]time.Time, VPMap[string, []time.Time, VPString[string], VPSlice[time.Time, VPTime[time.Time]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringTimeSliceV ¶
type MapStringTimeSliceV = FlagBaseV[map[string][]time.Time, VPMap[string, []time.Time, VPString[string], VPSlice[time.Time, VPTime[time.Time]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringTimeV ¶
type MapStringTimeV = FlagBaseV[map[string]time.Time, VPMap[string, time.Time, VPString[string], VPTime[time.Time]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint ¶
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint16 ¶
type MapStringUint16 = FlagBase[map[string]uint16, VPMap[string, uint16, VPString[string], VPUint[uint16]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint16Slice ¶
type MapStringUint16Slice = FlagBase[map[string][]uint16, VPMap[string, []uint16, VPString[string], VPSlice[uint16, VPUint[uint16]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint16SliceV ¶
type MapStringUint16SliceV = FlagBaseV[map[string][]uint16, VPMap[string, []uint16, VPString[string], VPSlice[uint16, VPUint[uint16]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint16Sum ¶
type MapStringUint16Sum = FlagBase[map[string]uint16, VPMap[string, uint16, VPString[string], VPSum[uint16, VPUint[uint16]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint16SumV ¶
type MapStringUint16SumV = FlagBaseV[map[string]uint16, VPMap[string, uint16, VPString[string], VPSum[uint16, VPUint[uint16]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint16V ¶
type MapStringUint16V = FlagBaseV[map[string]uint16, VPMap[string, uint16, VPString[string], VPUint[uint16]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint32 ¶
type MapStringUint32 = FlagBase[map[string]uint32, VPMap[string, uint32, VPString[string], VPUint[uint32]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint32Slice ¶
type MapStringUint32Slice = FlagBase[map[string][]uint32, VPMap[string, []uint32, VPString[string], VPSlice[uint32, VPUint[uint32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint32SliceV ¶
type MapStringUint32SliceV = FlagBaseV[map[string][]uint32, VPMap[string, []uint32, VPString[string], VPSlice[uint32, VPUint[uint32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint32Sum ¶
type MapStringUint32Sum = FlagBase[map[string]uint32, VPMap[string, uint32, VPString[string], VPSum[uint32, VPUint[uint32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint32SumV ¶
type MapStringUint32SumV = FlagBaseV[map[string]uint32, VPMap[string, uint32, VPString[string], VPSum[uint32, VPUint[uint32]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint32V ¶
type MapStringUint32V = FlagBaseV[map[string]uint32, VPMap[string, uint32, VPString[string], VPUint[uint32]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint64 ¶
type MapStringUint64 = FlagBase[map[string]uint64, VPMap[string, uint64, VPString[string], VPUint[uint64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint64Slice ¶
type MapStringUint64Slice = FlagBase[map[string][]uint64, VPMap[string, []uint64, VPString[string], VPSlice[uint64, VPUint[uint64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint64SliceV ¶
type MapStringUint64SliceV = FlagBaseV[map[string][]uint64, VPMap[string, []uint64, VPString[string], VPSlice[uint64, VPUint[uint64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint64Sum ¶
type MapStringUint64Sum = FlagBase[map[string]uint64, VPMap[string, uint64, VPString[string], VPSum[uint64, VPUint[uint64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint64SumV ¶
type MapStringUint64SumV = FlagBaseV[map[string]uint64, VPMap[string, uint64, VPString[string], VPSum[uint64, VPUint[uint64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint64V ¶
type MapStringUint64V = FlagBaseV[map[string]uint64, VPMap[string, uint64, VPString[string], VPUint[uint64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint8 ¶
type MapStringUint8 = FlagBase[map[string]uint8, VPMap[string, uint8, VPString[string], VPUint[uint8]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint8Slice ¶
type MapStringUint8Slice = FlagBase[map[string][]uint8, VPMap[string, []uint8, VPString[string], VPSlice[uint8, VPUint[uint8]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint8SliceV ¶
type MapStringUint8SliceV = FlagBaseV[map[string][]uint8, VPMap[string, []uint8, VPString[string], VPSlice[uint8, VPUint[uint8]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint8Sum ¶
type MapStringUint8Sum = FlagBase[map[string]uint8, VPMap[string, uint8, VPString[string], VPSum[uint8, VPUint[uint8]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint8SumV ¶
type MapStringUint8SumV = FlagBaseV[map[string]uint8, VPMap[string, uint8, VPString[string], VPSum[uint8, VPUint[uint8]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUint8V ¶
type MapStringUint8V = FlagBaseV[map[string]uint8, VPMap[string, uint8, VPString[string], VPUint[uint8]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintSlice ¶
type MapStringUintSlice = FlagBase[map[string][]uint, VPMap[string, []uint, VPString[string], VPSlice[uint, VPUint[uint]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintSliceV ¶
type MapStringUintSliceV = FlagBaseV[map[string][]uint, VPMap[string, []uint, VPString[string], VPSlice[uint, VPUint[uint]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintSum ¶
type MapStringUintSum = FlagBase[map[string]uint, VPMap[string, uint, VPString[string], VPSum[uint, VPUint[uint]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintSumV ¶
type MapStringUintSumV = FlagBaseV[map[string]uint, VPMap[string, uint, VPString[string], VPSum[uint, VPUint[uint]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintV ¶
type MapStringUintV = FlagBaseV[map[string]uint, VPMap[string, uint, VPString[string], VPUint[uint]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintptr ¶
type MapStringUintptr = FlagBase[map[string]uintptr, VPMap[string, uintptr, VPString[string], VPUint[uintptr]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintptrSlice ¶
type MapStringUintptrSlice = FlagBase[map[string][]uintptr, VPMap[string, []uintptr, VPString[string], VPSlice[uintptr, VPUint[uintptr]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintptrSliceV ¶
type MapStringUintptrSliceV = FlagBaseV[map[string][]uintptr, VPMap[string, []uintptr, VPString[string], VPSlice[uintptr, VPUint[uintptr]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintptrSum ¶
type MapStringUintptrSum = FlagBase[map[string]uintptr, VPMap[string, uintptr, VPString[string], VPSum[uintptr, VPUint[uintptr]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintptrSumV ¶
type MapStringUintptrSumV = FlagBaseV[map[string]uintptr, VPMap[string, uintptr, VPString[string], VPSum[uintptr, VPUint[uintptr]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUintptrV ¶
type MapStringUintptrV = FlagBaseV[map[string]uintptr, VPMap[string, uintptr, VPString[string], VPUint[uintptr]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixMicro ¶
type MapStringUnixMicro = FlagBase[map[string]int64, VPMap[string, int64, VPString[string], VPUnixMicro[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixMicroSlice ¶
type MapStringUnixMicroSlice = FlagBase[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPUnixMicro[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixMicroSliceV ¶
type MapStringUnixMicroSliceV = FlagBaseV[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPUnixMicro[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixMicroV ¶
type MapStringUnixMicroV = FlagBaseV[map[string]int64, VPMap[string, int64, VPString[string], VPUnixMicro[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixMilli ¶
type MapStringUnixMilli = FlagBase[map[string]int64, VPMap[string, int64, VPString[string], VPUnixMilli[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixMilliSlice ¶
type MapStringUnixMilliSlice = FlagBase[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPUnixMilli[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixMilliSliceV ¶
type MapStringUnixMilliSliceV = FlagBaseV[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPUnixMilli[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixMilliV ¶
type MapStringUnixMilliV = FlagBaseV[map[string]int64, VPMap[string, int64, VPString[string], VPUnixMilli[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixNano ¶
type MapStringUnixNano = FlagBase[map[string]int64, VPMap[string, int64, VPString[string], VPUnixNano[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixNanoSlice ¶
type MapStringUnixNanoSlice = FlagBase[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPUnixNano[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixNanoSliceV ¶
type MapStringUnixNanoSliceV = FlagBaseV[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPUnixNano[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixNanoV ¶
type MapStringUnixNanoV = FlagBaseV[map[string]int64, VPMap[string, int64, VPString[string], VPUnixNano[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixSec ¶
type MapStringUnixSec = FlagBase[map[string]int64, VPMap[string, int64, VPString[string], VPUnixSec[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixSecSlice ¶
type MapStringUnixSecSlice = FlagBase[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPUnixSec[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixSecSliceV ¶
type MapStringUnixSecSliceV = FlagBaseV[map[string][]int64, VPMap[string, []int64, VPString[string], VPSlice[int64, VPUnixSec[int64]]]]
predefined flag types for "<string>=<scalar>" from command line.
type MapStringUnixSecV ¶
type MapStringUnixSecV = FlagBaseV[map[string]int64, VPMap[string, int64, VPString[string], VPUnixSec[int64]]]
predefined flag types for "<string>=<scalar>" from command line.
type MultiIndexer ¶
type MultiIndexer struct {
Flags []FlagFinderMaybeIter
}
MultiIndexer combines multiple FlagFinders into one.
func (*MultiIndexer) FindFlag ¶
func (m *MultiIndexer) FindFlag(name string) (f Flag, ok bool)
FindFlag implements FlagFinder.
type MultiRule ¶
type MultiRule struct {
Rules []Rule
}
MultiRule
type ParseErrorHandleFunc ¶
type ParseErrorHandleFunc = func(opts *ParseOptions, args []string, posErrArg int, parseErr error) (err error)
ParseErrorHandleFunc handles the parseErr when parsing args[posErrArg].
Return nil to ignore the parseErr and continue parsing.
type ParseOptions ¶
type ParseOptions struct { // StartTime is assumed to be the time of parsing start. StartTime time.Time // HandleParseError is the function to handle flag parsing errors. HandleParseError ParseErrorHandleFunc // PosArgsBuf is the buffer used by ParseFlags{,LowLevel} for appending // positional args. PosArgsBuf []string // HelpArgs are arg values can initiate help request. // // - HelpArgs = nil, is equivalent to HelpArgs = []string{"--help", "-h", "help"}. // - HelpArgs = []string{} will disable the help system. // - otherwise, use the supplied HelpArgs to match args. HelpArgs []string // Extra custom data. Extra any }
ParseOptions are options for flag parsing.
func (*ParseOptions) IsHelpArg ¶
func (c *ParseOptions) IsHelpArg(x string) bool
IsHelpArg returns true if x is supposed to be an arg requesting help.
type PostRunFunc ¶
type PostRunFunc = func(opts *CmdOptions, route Route, postrunAt int, runErr error) error
PostRunFunc
route is the full Cmd route leading to the target, and route[postrunAt] is the Cmd that owns this PostRun.
runErr is the error returned by the Run func and can only be non-nil when passed to the first PostRun (not necessarily the one from the target Cmd).
Returning an error cancels all subsequent PostRun call and the error will be returned by Cmd.Exec.
type PreRunFunc ¶
type PreRunFunc = func(opts *CmdOptions, route Route, prerunAt int, posArgs, dashArgs []string) error
PreRunFunc
route is the full Cmd route leading to the target, and route[prerunAt] is the Cmd that owns this PreRun.
posArgs and dashArgs are meant for the target Cmd.
Return an error to cancel all subsequent PreRun calls and the error will be returned by Cmd.Exec.
type ReflectFlagRef ¶
type ReflectFlagRef struct { Field int Options string Flag *FlagReflect Info FlagInfo }
type ReflectIndexer ¶
type ReflectIndexer struct { // StructV is the reflect value of the addressable struct. StructV reflect.Value // Factory handles creation of VP[*reflect.Value] Factory ReflectVPFactory // Names maps name to index into Refs Names map[string]int // Refs are cached flags in struct field order Refs []ReflectFlagRef // TotalFlags is the count of flags in StructV // // When = 0: count unknown // When < 0: no flag // When > 0: n flags, len(Refs) = TotalFlags TotalFlags int }
A ReflectIndexer creates and caches flags on request using reflection.
Under most circumstances, an application runs with no more than 15 args but can have way more flags available, when dynamic allocation and reflection (binary size) is not a concern, a ReflectIndexer can speedup both your development and application startup.
Struct field tag specification
`cli:"<long name>|<shorthand>[,comp=<completion>][,value=<type>][,key=<type>][,def=<default>][,hide][,once][,#<brief usage>]"`
Text before the first comma (',') is interpreted as flag name section, it SHOULD contain at most two names (one long name and one shorthand), use pipe ('|') to separate names.
Text after the first comma and before the sharp ('#') is interpreted as flag options, currently there are six options available:
- comp=<completion>
- value=<type>
- key=<type>
- def=<value>
- hide
- once
Option `comp` defines completion values, multiple `comp` option creates multiple CompItems, for example:
type Example struct{ Foo string `cli:"foo,comp=value1,comp=value2"` }
The ReflectIndexer will produce two CompItems for field Foo's command-line flag `--foo`:
- value1
- value2
Option `value` is used to change the method used to decode text arg and can have one of following `<type>` values when using DefaultReflectVPFactory:
- size (size value, example command-line arg: "1TB", "1g1M")
- dur (duration value, example command-line arg: "1yr", "1m10s")
- sum (sums numeric values)
- ssum (sums size values)
- dsum (sums duration values)
- regexp
- regexp-nocase
- time (decode time string, example command-line arg: "15:00", "21")
- unix-ts (decode time string to seconds since the unix epoch)
- unix-ms (decode time string to milliseconds since the unix epoch)
- unix-us (decode time string to microseconds since the unix epoch)
- unix-ns (decode time string to nanoseconds since the unix epoch)
Option `value`'s meaning varies depending on the field type:
- scalar field: for that scalar field (e.g. `value=dur` for int64)
- slice field: for slice element type (e.g. `value=unix-ts` for uint64 in []uint64)
- map field: for map value type (e.g. `value=regexp` for *regexp.Regexp in map[K]*regexp.Regexp)
Option `key` is meant for map key, and works the same way as `value`. It can have one of following values when using DefaultReflectVPFactory:
- size
- dur
- time
- unix-ts
- unix-ms
- unix-us
- unix-ns
Both option `value` and option `key` can present at most once in the tag value.
Option `def` defines a default value for the flag when flag is not set. There can be multiple `def` options.
Option `hide` marks the FlagState with FlagStateHidden. There can be no more than one `hide` option.
Option `once` marks the FlagState with FlagStateSetAtMostOnce. There can be no more than one `once` option.
The remaining text after the sharp sign ('#') after the first comma, is interpreted as the brief usage of the flag.
NOTE: Unexported fields and fields without a `cli` tag value are ignored.
func NewReflectIndexer ¶
func NewReflectIndexer(factory ReflectVPFactory, pStruct any) *ReflectIndexer
NewReflectIndexer creates a new ReflectIndexer for the pointer to struct.
type ReflectVPFactory ¶
type ReflectVPFactory interface {
GetVPReflectFor(fieldType reflect.Type, keyType, valueType string) (VP[*reflect.Value], error)
}
ReflectVPFactory handles creation of VP[*reflect.Value] for struct fields.
type RegexpNocase ¶
type RegexpNocase = FlagBase[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]
predefined flag types for scalar values from command line.
type RegexpNocaseSlice ¶
type RegexpNocaseSlice = FlagBase[[]*regexp.Regexp, VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]]
predefined flag types for slice values from command line.
type RegexpNocaseSliceV ¶
type RegexpNocaseSliceV = FlagBaseV[[]*regexp.Regexp, VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexpNocase[regexp.Regexp]]]]
predefined flag types for slice values from command line.
type RegexpNocaseV ¶
predefined flag types for scalar values from command line.
type RegexpSlice ¶
type RegexpSlice = FlagBase[[]*regexp.Regexp, VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexp[regexp.Regexp]]]]
predefined flag types for slice values from command line.
type RegexpSliceV ¶
type RegexpSliceV = FlagBaseV[[]*regexp.Regexp, VPSlice[*regexp.Regexp, VPPointer[regexp.Regexp, VPRegexp[regexp.Regexp]]]]
predefined flag types for slice values from command line.
type Route ¶
type Route []*Cmd
Route contains the route leading from the root Cmd to the target Cmd.
func (*Route) CheckFlagValueChanged ¶
CheckFlagValueChanged implements Inspector.
func (*Route) FindFlag ¶
FindFlag implements FlagFinder.
type Rule ¶
type Rule interface { // Requires returns true if this rule requires Inspector.CheckFlagValueChanged() to // return true for this key to avoid violation. Requires(key string) bool // Contains returns true if the rule has something to do with the key. Contains(key string) bool // NthEx returns (i-th violation, true), if any, otherwise (_, false). NthEx(f Inspector, i int) (Violation, bool) // WriteFlagRule writes text representation of the rule. // // If len(keys) > 0, only add rule applies to at least one of the keys, // otherwise add all. WriteFlagRule(out io.Writer, keys ...string) (int, error) }
Rule
func MergeFlagRules ¶
MergeFlagRules merges multiple Rules into one.
type RuleAllOf ¶
type RuleAllOf struct {
Keys []string
}
type RuleAllOrNone ¶
type RuleAllOrNone struct {
Keys []string
}
RuleAllOrNone represents a group of keys MUST either all set or all not set.
func AllOrNone ¶
func AllOrNone(keys ...string) *RuleAllOrNone
AllOrNone creates a *RuleAllOrNone from provided keys.
func (*RuleAllOrNone) Contains ¶
func (r *RuleAllOrNone) Contains(key string) bool
func (*RuleAllOrNone) NthEx ¶
func (r *RuleAllOrNone) NthEx(f Inspector, i int) (Violation, bool)
NthEx implements Rule.
func (*RuleAllOrNone) Requires ¶
func (r *RuleAllOrNone) Requires(key string) bool
func (*RuleAllOrNone) WriteFlagRule ¶
type RuleAnyOf ¶
type RuleAnyOf struct {
Keys []string
}
RuleAnyOf represents a group of flags that at least one MUST present.
type RuleDepends ¶
type RuleDepends[X, Y, Z Rule] struct { // If rules in `If` produces no violation, `Then` is used to decide // this rule has been satisfied if `Then` produces no violation. // // `Else` is used as `Then` if `If` produced violation. // // It is valid that `If` contains no rule. If X Then Y Else Z }
RuleDepends represents a group of flags required only when dependent rules are met.
func DependOn ¶
func DependOn[X, Y, Z Rule](ifX X, thenY Y, elseZ Z) *RuleDepends[X, Y, Z]
DependOn creates a *RuleDepends from the given condition and branches.
func (*RuleDepends[X, Y, Z]) Contains ¶
func (r *RuleDepends[X, Y, Z]) Contains(key string) bool
func (*RuleDepends[X, Y, Z]) NthEx ¶
func (r *RuleDepends[X, Y, Z]) NthEx(f Inspector, i int) (p Violation, ok bool)
NthEx implements Rule.
func (*RuleDepends[X, Y, Z]) Requires ¶
func (r *RuleDepends[X, Y, Z]) Requires(key string) bool
func (*RuleDepends[X, Y, Z]) WriteFlagRule ¶
type RuleOneOf ¶
type RuleOneOf struct {
Keys []string
}
RuleOneOf defines a group of mutually exclusive flags.
type RunFunc ¶
type RunFunc = func(opts *CmdOptions, route Route, posArgs, dashArgs []string) error
RunFunc
function parameters' definition is the same as PreRun.
type SizeSliceV ¶
predefined flag types for slice values from command line.
type StringSlice ¶
predefined flag types for slice values from command line.
type StringSliceV ¶
predefined flag types for slice values from command line.
type TimeSliceV ¶
predefined flag types for slice values from command line.
type Uint16Slice ¶
predefined flag types for slice values from command line.
type Uint16SliceV ¶
predefined flag types for slice values from command line.
type Uint16SumV ¶
predefined flag types for sumed scalar values from command line.
type Uint32Slice ¶
predefined flag types for slice values from command line.
type Uint32SliceV ¶
predefined flag types for slice values from command line.
type Uint32SumV ¶
predefined flag types for sumed scalar values from command line.
type Uint64Slice ¶
predefined flag types for slice values from command line.
type Uint64SliceV ¶
predefined flag types for slice values from command line.
type Uint64SumV ¶
predefined flag types for sumed scalar values from command line.
type Uint8Slice ¶
predefined flag types for slice values from command line.
type Uint8SliceV ¶
predefined flag types for slice values from command line.
type UintSliceV ¶
predefined flag types for slice values from command line.
type UintptrSlice ¶
predefined flag types for slice values from command line.
type UintptrSliceV ¶
predefined flag types for slice values from command line.
type UintptrSum ¶
predefined flag types for sumed scalar values from command line.
type UintptrSumV ¶
predefined flag types for sumed scalar values from command line.
type UnixMicro ¶
type UnixMicro = FlagBase[int64, VPUnixMicro[int64]]
predefined flag types for scalar values from command line.
type UnixMicroSlice ¶
predefined flag types for slice values from command line.
type UnixMicroSliceV ¶
predefined flag types for slice values from command line.
type UnixMicroV ¶
type UnixMicroV = FlagBaseV[int64, VPUnixMicro[int64]]
predefined flag types for scalar values from command line.
type UnixMilli ¶
type UnixMilli = FlagBase[int64, VPUnixMilli[int64]]
predefined flag types for scalar values from command line.
type UnixMilliSlice ¶
predefined flag types for slice values from command line.
type UnixMilliSliceV ¶
predefined flag types for slice values from command line.
type UnixMilliV ¶
type UnixMilliV = FlagBaseV[int64, VPUnixMilli[int64]]
predefined flag types for scalar values from command line.
type UnixNano ¶
type UnixNano = FlagBase[int64, VPUnixNano[int64]]
predefined flag types for scalar values from command line.
type UnixNanoSlice ¶
predefined flag types for slice values from command line.
type UnixNanoSliceV ¶
predefined flag types for slice values from command line.
type UnixNanoV ¶
type UnixNanoV = FlagBaseV[int64, VPUnixNano[int64]]
predefined flag types for scalar values from command line.
type UnixSecSlice ¶
predefined flag types for slice values from command line.
type UnixSecSliceV ¶
predefined flag types for slice values from command line.
type VP ¶
type VP[T any] interface { // Type returns the VPType handled by the VP. // // NOTE: It SHOULD return VPTypeUnkown for types cannot represented by // VPType, see definition of VPType for more details. Type() VPType // HasValue returns true if v is considered having value. HasValue(v T) bool // ParseValue parses an arg string as value of type T. // // NOTE: Implementation MUST handle nil ParseOptions. ParseValue(opts *ParseOptions, arg string, out T, set bool) error // PrintValue writes text representation of v to out. PrintValue(out io.Writer, value T) (int, error) }
VP is the acronym for ValuePeeker, ValueParser and ValuePrinter.
type VPBool ¶
type VPBool[T ~bool] struct{}
VPBool for types compatible with bool.
These args are considered true: "true", "yes", "y", "on", "1"
These args are considered false: "false", "no", "n", "off", "0"
All other values are invalid.
func (VPBool[T]) ParseValue ¶
func (VPBool[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) error
type VPDuration ¶
type VPDuration[T integer] struct{}
VPDuration decoding duration values to nanoseconds integer. Only decimal numbers are supported, other number format may cause silent error.
Supported units:
- `ns` (nanoseconds)
- `us` (microseconds)
- `ms` (milliseconds)
- `s` (seconds)
- `m` (minutes)
- `h` or `hr` (hours)
- `d` (days)
- `w` (weeks)
- `M` or `mt` (months)
- `y` or `yr` (years)
For example:
1000ns, 200us, 100ms, 1s, 2m, 3h, 4d, 5w, 6M, 6y, 1d2h, 5w3d
NOTE: Months and years MUST be integer values, they are non-deterministic and are based on the time from opts.StartTime or time.Now(). All other units are deterministic.
func (VPDuration[T]) HasValue ¶
func (VPDuration[T]) HasValue(v *T) bool
func (VPDuration[T]) ParseValue ¶
func (VPDuration[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
func (VPDuration[T]) PrintValue ¶
func (VPDuration[T]) PrintValue(out io.Writer, v *T) (int, error)
func (VPDuration[T]) Type ¶
func (VPDuration[T]) Type() VPType
type VPFloat ¶
type VPFloat[T float] struct{}
VPFloat for types compatible with float{32, 64}.
It uses strconv.ParseFloat to parse args.
func (VPFloat[T]) ParseValue ¶
func (VPFloat[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) error
type VPInt ¶
type VPInt[T sinteger] struct{}
VPInt for types compatible with int{, 8, 16, 32, 64}.
It uses strconv.ParseInt to parse args.
func (VPInt[T]) ParseValue ¶
func (VPInt[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
type VPMap ¶
type VPMap[K comparable, E any, KP VP[*K], EP VP[*E]] struct { Key KP Value EP }
VPMap wraps other VPs for parsing map[K]E types.
It parses args as "key=value" pairs.
func (VPMap[K, E, KP, EP]) ParseValue ¶
func (m VPMap[K, E, KP, EP]) ParseValue(opts *ParseOptions, arg string, out *map[K]E, set bool) (err error)
func (VPMap[K, E, KP, EP]) PrintValue ¶
type VPNop ¶
type VPNop[T any] struct{}
VPNop does absolutely nothing.
func (VPNop[T]) ParseValue ¶
func (VPNop[T]) ParseValue(*ParseOptions, string, T, bool) error
type VPPointer ¶
VPPointer wraps other VP for parsing *T types.
func (VPPointer[T, P]) ParseValue ¶
func (p VPPointer[T, P]) ParseValue(opts *ParseOptions, arg string, out **T, set bool) (err error)
func (VPPointer[T, P]) PrintValue ¶
type VPReflectBool ¶
type VPReflectBool struct{}
VPReflectBool is the reflect version of VPBool.
It accepts arbitrary depth of pointers.
func (VPReflectBool) ParseValue ¶
func (VPReflectBool) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectBool) PrintValue ¶
func (VPReflectBool) Type ¶
func (VPReflectBool) Type() VPType
type VPReflectDuration ¶
type VPReflectDuration struct{}
VPReflectDuration is the reflect version of VPDuration.
It accepts arbitrary depth of pointers.
func (VPReflectDuration) ParseValue ¶
func (VPReflectDuration) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectDuration) PrintValue ¶
func (VPReflectDuration) Type ¶
func (VPReflectDuration) Type() VPType
type VPReflectFloat ¶
type VPReflectFloat struct{}
VPReflectFloat is the reflect version of VPFloat.
It accepts arbitrary depth of pointers.
func (VPReflectFloat) ParseValue ¶
func (VPReflectFloat) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectFloat) PrintValue ¶
func (VPReflectFloat) Type ¶
func (VPReflectFloat) Type() VPType
type VPReflectInt ¶
type VPReflectInt struct{}
VPReflectInt is the reflect version of VPInt.
It accepts arbitrary depth of pointers.
func (VPReflectInt) ParseValue ¶
func (VPReflectInt) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectInt) PrintValue ¶
func (VPReflectInt) Type ¶
func (VPReflectInt) Type() VPType
type VPReflectMap ¶
VPReflectMap is the reflect version of VPMap.
It accepts arbitrary depth of pointers.
func (VPReflectMap[K, V]) HasValue ¶
func (vp VPReflectMap[K, V]) HasValue(value *reflect.Value) bool
func (VPReflectMap[K, V]) ParseValue ¶
func (vp VPReflectMap[K, V]) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectMap[K, V]) PrintValue ¶
func (VPReflectMap[K, V]) Type ¶
func (vp VPReflectMap[K, V]) Type() VPType
type VPReflectRegexp ¶
type VPReflectRegexp struct{}
VPReflectRegexp is the reflect version of VPRegexp.
It accepts arbitrary depth of pointers.
func (VPReflectRegexp) ParseValue ¶
func (VPReflectRegexp) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectRegexp) PrintValue ¶
func (VPReflectRegexp) Type ¶
func (VPReflectRegexp) Type() VPType
type VPReflectRegexpNocase ¶
type VPReflectRegexpNocase struct{}
VPReflectRegexpNocase is the reflect version of VPRegexpNocase.
It accepts arbitrary depth of pointers.
func (VPReflectRegexpNocase) HasValue ¶
func (VPReflectRegexpNocase) HasValue(v *reflect.Value) bool
func (VPReflectRegexpNocase) ParseValue ¶
func (VPReflectRegexpNocase) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectRegexpNocase) PrintValue ¶
func (VPReflectRegexpNocase) Type ¶
func (VPReflectRegexpNocase) Type() VPType
type VPReflectSize ¶
type VPReflectSize struct{}
VPReflectSize is the reflect version of VPSize.
It accepts arbitrary depth of pointers.
func (VPReflectSize) ParseValue ¶
func (VPReflectSize) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectSize) PrintValue ¶
func (VPReflectSize) Type ¶
func (VPReflectSize) Type() VPType
type VPReflectSlice ¶
VPReflectSlice is the reflect version of VPSlice.
It accepts arbitrary depth of pointers.
func (VPReflectSlice[EP]) HasValue ¶
func (vp VPReflectSlice[EP]) HasValue(value *reflect.Value) bool
func (VPReflectSlice[EP]) ParseValue ¶
func (vp VPReflectSlice[EP]) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectSlice[EP]) PrintValue ¶
func (VPReflectSlice[EP]) Type ¶
func (vp VPReflectSlice[EP]) Type() VPType
type VPReflectString ¶
type VPReflectString struct{}
VPReflectString is the reflect version of VPString.
It accepts arbitrary depth of pointers.
func (VPReflectString) ParseValue ¶
func (VPReflectString) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectString) PrintValue ¶
func (VPReflectString) Type ¶
func (VPReflectString) Type() VPType
type VPReflectSum ¶
VPReflectSum is the reflect version of VPSum.
It accepts arbitrary depth of pointers.
func (VPReflectSum[P]) ParseValue ¶
func (vp VPReflectSum[P]) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectSum[P]) PrintValue ¶
func (VPReflectSum[P]) Type ¶
func (vp VPReflectSum[P]) Type() VPType
type VPReflectTime ¶
type VPReflectTime struct{}
VPReflectTime is the reflect version of VPTime.
It accepts arbitrary depth of pointers.
func (VPReflectTime) ParseValue ¶
func (VPReflectTime) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectTime) PrintValue ¶
func (VPReflectTime) Type ¶
func (VPReflectTime) Type() VPType
type VPReflectUint ¶
type VPReflectUint struct{}
VPReflectUint is the reflect version of VPUint.
It accepts arbitrary depth of pointers.
func (VPReflectUint) ParseValue ¶
func (VPReflectUint) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectUint) PrintValue ¶
func (VPReflectUint) Type ¶
func (VPReflectUint) Type() VPType
type VPReflectUnixMicro ¶
type VPReflectUnixMicro struct{}
VPReflectUnixMicro is the reflect version of VPUnixMicro.
It accepts arbitrary depth of pointers.
func (VPReflectUnixMicro) ParseValue ¶
func (VPReflectUnixMicro) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectUnixMicro) PrintValue ¶
func (VPReflectUnixMicro) Type ¶
func (VPReflectUnixMicro) Type() VPType
type VPReflectUnixMilli ¶
type VPReflectUnixMilli struct{}
VPReflectUnixMilli is the reflect version of VPUnixMilli.
It accepts arbitrary depth of pointers.
func (VPReflectUnixMilli) ParseValue ¶
func (VPReflectUnixMilli) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectUnixMilli) PrintValue ¶
func (VPReflectUnixMilli) Type ¶
func (VPReflectUnixMilli) Type() VPType
type VPReflectUnixNano ¶
type VPReflectUnixNano struct{}
VPReflectUnixNano is the reflect version of VPUnixNano.
It accepts arbitrary depth of pointers.
func (VPReflectUnixNano) ParseValue ¶
func (VPReflectUnixNano) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectUnixNano) PrintValue ¶
func (VPReflectUnixNano) Type ¶
func (VPReflectUnixNano) Type() VPType
type VPReflectUnixSec ¶
type VPReflectUnixSec struct{}
VPReflectUnixSec is the reflect version of VPUnixSec.
It accepts arbitrary depth of pointers.
func (VPReflectUnixSec) ParseValue ¶
func (VPReflectUnixSec) ParseValue(opts *ParseOptions, arg string, value *reflect.Value, set bool) (err error)
func (VPReflectUnixSec) PrintValue ¶
func (VPReflectUnixSec) Type ¶
func (VPReflectUnixSec) Type() VPType
type VPRegexp ¶
VPRegexp for types compatible regexp.Regexp.
When parsing, it compiles the arg as a regular expression using regexp.Compile.
func (VPRegexp[T]) ParseValue ¶
func (VPRegexp[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
type VPRegexpNocase ¶
VPRegexpNocase is VPRegexp but compiles pattern as case-insensitive.
By adding prefix `(?i:` and suffix `)`
func (VPRegexpNocase[T]) HasValue ¶
func (VPRegexpNocase[T]) HasValue(v *T) bool
func (VPRegexpNocase[T]) ParseValue ¶
func (VPRegexpNocase[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
func (VPRegexpNocase[T]) PrintValue ¶
func (VPRegexpNocase[T]) PrintValue(out io.Writer, v *T) (int, error)
func (VPRegexpNocase[T]) Type ¶
func (VPRegexpNocase[T]) Type() VPType
type VPSize ¶
type VPSize[T integer] struct{}
VPSize for size strings with suffix:
b, B, k, KB, g, GB, t, TB, p, PB, e, EB
parsed value is the size in bytes, size overflow will cause error
func (VPSize[T]) ParseValue ¶
func (VPSize[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
func (VPSize[T]) PrintValue ¶
type VPSlice ¶
VPSlice wraps other VP for parsing []T types.
It appends value parsed by the inner VP to []T.
func (VPSlice[E, EP]) ParseValue ¶
func (s VPSlice[E, EP]) ParseValue(opts *ParseOptions, arg string, out *[]E, set bool) (err error)
func (VPSlice[E, EP]) PrintValue ¶
type VPString ¶
type VPString[T ~string] struct{}
VPString for types compatible with string.
It does nothing validating args, so all kinds of strings are accepted.
func (VPString[T]) ParseValue ¶
func (VPString[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) error
type VPSum ¶
type VPSum[T num, P VP[*T]] struct{}
VPSum sums numeric values.
NOTE: It is not recommended to use VPSum with VPSlice, unless you known what you are doing.
func (VPSum[T, P]) ParseValue ¶
func (VPSum[T, P]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
type VPTime ¶
VPTime for time values like:
- 15:04
- 2006-01-02
- 2006-01-02T15:04:05
- 2006-01-02T15:04:05Z07:00
- 15:04:05
- 15
To parse value, it uses opts.StartTime or time.Now() to fill missing date parts.
func (VPTime[T]) ParseValue ¶
func (VPTime[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
type VPType ¶
type VPType uint32
VPType represents the type a VP is handling.
It is limited to one of following types:
- scalar type.
- slice of scalar.
- map of scalar (key) to scalar/slice (value).
Memory layout:
map elem variant: VPTypeMapElemVariantSlice/VPTypeMapElemVariantSum | | 0x 0 0 0 0 0 0 0 0 [map key scalar] | [ value scalar ] | type variant: VPTypeVariantSlice/VPTypeVariantSum as variant for the value scalar, all bits on the left should be 0. VPTypeVariantMap as variant for the whole type, in this case, map elem variant is for the value scalar [ map only bits ] (only used when type variant is map)
const ( VPTypeUnknown VPType = iota VPTypeString VPTypeBool VPTypeInt VPTypeUint VPTypeFloat VPTypeSize VPTypeDuration VPTypeTime VPTypeTimestampUnixSec VPTypeTimestampUnixMilli VPTypeTimestampUnixMicro VPTypeTimestampUnixNano VPTypeRegexp VPTypeRegexpNocase VPTypeScalarMAX VPTypeElemScalarMASK VPType = 0x00000fff VPTypeKeyScalarMASK VPType = 0x0fff0000 // variant mask for the whole type VPTypeVariantMASK VPType = 0x0000f000 VPTypeVariantSlice VPType = 0x00001000 VPTypeVariantSum VPType = 0x00002000 VPTypeVariantMap VPType = 0x00003000 // variant mask for the map value type (only used when VPTypeVariantMap is set) VPTypeMapElemVariantMASK VPType = 0xf0000000 VPTypeMapElemVariantSlice VPType = 0x10000000 VPTypeMapElemVariantSum VPType = 0x20000000 VPTypeVariantShift VPType = 12 VPTypeKeyScalarShift VPType = 16 VPTypeMapElemVariantShift VPType = 28 )
type VPUint ¶
type VPUint[T uinteger] struct{}
VPUint for types compatible with uint{, 8, 16, 32, 64, ptr}.
It uses strconv.ParseUint to parse args.
func (VPUint[T]) ParseValue ¶
func (VPUint[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
func (VPUint[T]) PrintValue ¶
type VPUnixMicro ¶
type VPUnixMicro[T ~int64] struct{}
VPUnixMicro is like VPTime but the target value is microseconds since the unix epoch.
func (VPUnixMicro[T]) HasValue ¶
func (VPUnixMicro[T]) HasValue(v *T) bool
func (VPUnixMicro[T]) ParseValue ¶
func (VPUnixMicro[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
func (VPUnixMicro[T]) PrintValue ¶
func (VPUnixMicro[T]) PrintValue(out io.Writer, value *T) (int, error)
func (VPUnixMicro[T]) Type ¶
func (VPUnixMicro[T]) Type() VPType
type VPUnixMilli ¶
type VPUnixMilli[T ~int64] struct{}
VPUnixMilli is like VPTime but the target value is milliseconds since the unix epoch.
func (VPUnixMilli[T]) HasValue ¶
func (VPUnixMilli[T]) HasValue(v *T) bool
func (VPUnixMilli[T]) ParseValue ¶
func (VPUnixMilli[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
func (VPUnixMilli[T]) PrintValue ¶
func (VPUnixMilli[T]) PrintValue(out io.Writer, value *T) (int, error)
func (VPUnixMilli[T]) Type ¶
func (VPUnixMilli[T]) Type() VPType
type VPUnixNano ¶
type VPUnixNano[T ~int64] struct{}
VPUnixNano is like VPTime but the target value is nanoseconds since the unix epoch.
func (VPUnixNano[T]) HasValue ¶
func (VPUnixNano[T]) HasValue(v *T) bool
func (VPUnixNano[T]) ParseValue ¶
func (VPUnixNano[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
func (VPUnixNano[T]) PrintValue ¶
func (VPUnixNano[T]) PrintValue(out io.Writer, value *T) (int, error)
func (VPUnixNano[T]) Type ¶
func (VPUnixNano[T]) Type() VPType
type VPUnixSec ¶
type VPUnixSec[T ~int64] struct{}
VPUnixSec is like VPTime but the target value is seconds since the unix epoch.
func (VPUnixSec[T]) ParseValue ¶
func (VPUnixSec[T]) ParseValue(opts *ParseOptions, arg string, out *T, set bool) (err error)
func (VPUnixSec[T]) PrintValue ¶
type Violation ¶
type Violation struct { Key string Reason ViolationCode }
type ViolationCode ¶
type ViolationCode uint32
const ( ViolationCodeNoViolation ViolationCode = iota ViolationCodeEmptyAllOf // for RuleAllOf: none present. ViolationCodePartialAllOf // for RuleAllOf: at least one present but not all present. ViolationCodePartialAllOrNone // for RuleAllOrNone: at least one present but not all present. ViolationCodeExcessiveOneOf // for RuleOneOf: more than one present. ViolationCodeEmptyOneOf // for RuleOneOf: none present. ViolationCodeEmptyAnyOf // for RuleAnyOf: none present. )