opts

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Opt

type Opt interface {
	Name() string
	Short() string
	Help() string
	Default() reflect.Value
	Value() reflect.Value
	Item() Value
	FromEnv() bool
	EnvName() string
	HasSet() bool
}

Opt is a single option

type Opts

type Opts interface {
	Parse() ParsedOpts
	Opts() []Opt
}

Opts contains flags, args and commands

func New

func New(config interface{}) Opts

New create a Opts

type ParsedOpts

type ParsedOpts interface {
	//Help returns the final help text
	Help() string
	//IsRunnable returns whether the matched command has a Run method
	IsRunnable() bool
	//Run assumes the matched command is runnable and executes its Run method.
	//The target Run method must be 'Run() error' or 'Run()'
	Run() error
	//RunFatal assumes the matched command is runnable and executes its Run method.
	//However, any error will be printed, followed by an exit(1).
	RunFatal()
}

ParsedOpts ...

type Setter

type Setter interface {
	Set(string) error
}

Setter is any type which can be set from a string. This includes flag.Value.

type Value added in v0.0.8

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

Value is the interface to the dynamic value stored in a flag. (The default value is represented as a string.)

Jump to

Keyboard shortcuts

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