Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ExitOK = &ExitError{}
ExitOK is used to signal that after running PreRun, the application should exit instead of continuing to execute Run.
Functions ¶
func FlagValueImplicit ¶
func FlagValueImplicit(v string) flagValueSpec
FlagValueImplicit signals that if a flag is set, the flag value may be explicitly set. If the flag's value isn't set, the given implicit value should be used.
func FlagValueNone ¶
func FlagValueNone() flagValueSpec
FlagValueNone signals that this flag cannot have a value set.
func FlagValueRequired ¶
func FlagValueRequired() flagValueSpec
FlagValueRequired signals that this flag must explicitly set a value.
Types ¶
type Command ¶
type Command interface {
CommandSpec() CommandSpec
ValueSpecs() []ValueSpec
Run(*Values) error
}
Command is an instance of a command or subcommand to run.
type CommandSpec ¶
type CommandSpec struct {
Name string
Args []string
Summary string
Description string
Subcommands []Command
}
CommandSpec contains info about a Command.
type CompletionsCommand ¶ added in v0.2.0
type CompletionsCommand struct{}
CompletionsCommand is a command that generates a Bash script for triggering shell command completions.
func (*CompletionsCommand) CommandSpec ¶ added in v0.2.0
func (c *CompletionsCommand) CommandSpec() CommandSpec
CommandSpec returns command details about the completions command.
func (*CompletionsCommand) Run ¶ added in v0.2.0
func (c *CompletionsCommand) Run(vs *Values) error
Run returns a script for triggering shell completions.
func (*CompletionsCommand) ValueSpecs ¶ added in v0.2.0
func (c *CompletionsCommand) ValueSpecs() []ValueSpec
CommandSpec returns value details about the completions command.
type Runner ¶
type Runner struct {
Args []string
Env []string
// PreRun is a function that gets run before a Command's Run function gets
// called.
PreRun func(Command, *Values) error
}
Runner runs Commands.
type ValueSpec ¶
type ValueSpec struct {
// ID is an ID for this value. If this isn't explicitly set, the longest
// flag name will be used.
ID string
Description string
// Flags is a list of flags this value should read from.
Flags []string
// FlagValue sets the style of values Flags can have.
FlagValue flagValueSpec
// Env is a list of environment variables this value should read from.
Env []string
// Default is the default value this value has.
Default string
// Group is a group name that this value belongs to. Groups are mutually
// exclusive.
Group string
}
ValueSpec contains information about a specific value.
type Values ¶
type Values struct {
// contains filtered or unexported fields
}
Values provides access to all values collected for the Command.
func (*Values) CommandLine ¶ added in v0.2.0
CommandLine is the full argument vector for this executable.