Documentation
¶
Index ¶
- func CanonicalOption(arg string) string
- func IsOptionError(err error) bool
- func IsTask(arg string) bool
- func IsTaskFlag(arg string) bool
- func KnownOption(arg string) bool
- func OptionTakesSeparateValue(arg string) bool
- func PrepareArguments(args []string) []string
- func ShortOptionTakesAttachedValue(flag byte) bool
- func SupportedLogLevel(level string) bool
- func ValidateOptions(args []string) error
- type Option
- type OptionDocumentation
- type OptionError
- type ValueArity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalOption ¶ added in v0.0.5
CanonicalOption returns the canonical option name for arg if it is known.
func IsOptionError ¶
IsOptionError reports whether err came from option validation.
func IsTaskFlag ¶ added in v0.0.5
IsTaskFlag reports whether arg is an option that maps to an app task.
func KnownOption ¶ added in v0.0.5
KnownOption reports whether arg names an accepted CLI option.
func OptionTakesSeparateValue ¶ added in v0.0.5
OptionTakesSeparateValue reports whether arg consumes the next argument.
func PrepareArguments ¶
PrepareArguments preserves Facter's command precedence: known command flags are moved before normal flags, and bare fact names become query arguments.
func ShortOptionTakesAttachedValue ¶ added in v0.0.5
ShortOptionTakesAttachedValue reports whether a short option supports -xVALUE.
func SupportedLogLevel ¶
SupportedLogLevel reports whether level is accepted by Ruby-compatible log-level validation.
func ValidateOptions ¶
ValidateOptions reports invalid option combinations before command execution, matching Ruby Facter's validator.
Types ¶
type Option ¶ added in v0.0.5
type Option struct {
Canonical string
Aliases []string
Arity ValueArity
Repeatable bool
TaskFlag bool
Hidden bool
Conflicts []string
Documentation OptionDocumentation
}
Option describes one accepted command-line option and its aliases.
func DocumentedOptions ¶ added in v0.0.5
func DocumentedOptions() []Option
DocumentedOptions returns all accepted CLI options that should appear in docs.
func LookupOption ¶ added in v0.0.5
LookupOption returns metadata for arg, accepting aliases and inline values.
type OptionDocumentation ¶ added in v0.0.5
OptionDocumentation holds the help and manual rows for a visible option.
type OptionError ¶
type OptionError struct {
Err error
}
OptionError identifies command-line option validation failures.
func (*OptionError) Error ¶
func (oe *OptionError) Error() string
func (*OptionError) Unwrap ¶
func (oe *OptionError) Unwrap() error
type ValueArity ¶ added in v0.0.5
type ValueArity int
ValueArity describes whether a CLI option consumes a value.
const ( NoValue ValueArity = iota RequiredValue )