cli

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalOption added in v0.0.5

func CanonicalOption(arg string) string

CanonicalOption returns the canonical option name for arg if it is known.

func IsOptionError

func IsOptionError(err error) bool

IsOptionError reports whether err came from option validation.

func IsTask added in v0.0.5

func IsTask(arg string) bool

IsTask reports whether arg is a bare app task name.

func IsTaskFlag added in v0.0.5

func IsTaskFlag(arg string) bool

IsTaskFlag reports whether arg is an option that maps to an app task.

func KnownOption added in v0.0.5

func KnownOption(arg string) bool

KnownOption reports whether arg names an accepted CLI option.

func OptionTakesSeparateValue added in v0.0.5

func OptionTakesSeparateValue(arg string) bool

OptionTakesSeparateValue reports whether arg consumes the next argument.

func PrepareArguments

func PrepareArguments(args []string) []string

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

func ShortOptionTakesAttachedValue(flag byte) bool

ShortOptionTakesAttachedValue reports whether a short option supports -xVALUE.

func SupportedLogLevel

func SupportedLogLevel(level string) bool

SupportedLogLevel reports whether level is accepted by Ruby-compatible log-level validation.

func ValidateOptions

func ValidateOptions(args []string) error

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

func LookupOption(arg string) (Option, bool)

LookupOption returns metadata for arg, accepting aliases and inline values.

func Options added in v0.0.5

func Options() []Option

Options returns all accepted CLI options in documentation order.

type OptionDocumentation added in v0.0.5

type OptionDocumentation struct {
	Help string
	Man  string
}

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
)

Jump to

Keyboard shortcuts

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