Documentation
¶
Index ¶
- Constants
- func ArgumentAsString(arguments []Argument) string
- func CommandErrorText(cmd NamedCommand) string
- func CommandHelp(c Command) string
- func Commands(metaPtr *Meta, agentUi cli.Ui, commands CommandFunc) map[string]cli.CommandFactory
- func ExampleString(examples map[string]string) string
- func FlagString(flags *flag.FlagSet) string
- func GeneralOptionsUsage(c Command) string
- func MergeAutocompleteFlags(flags ...complete.Flags) complete.Flags
- func ParseArguments(args []string, arguments []Argument) (map[string]Argument, error)
- func SetupEnv(args []string) []string
- type Argument
- type ArgumentType
- type Command
- type CommandFunc
- type FlagSetFlags
- type GlobalFlagCommand
- type Meta
- type NamedCommand
- type VersionCommand
- func (c *VersionCommand) Arguments() []Argument
- func (c *VersionCommand) AutocompleteArgs() complete.Predictor
- func (c *VersionCommand) AutocompleteFlags() complete.Flags
- func (c *VersionCommand) Examples() map[string]string
- func (c *VersionCommand) FlagSet() *flag.FlagSet
- func (c *VersionCommand) Help() string
- func (c *VersionCommand) Name() string
- func (c *VersionCommand) ParsedArguments(args []string) (map[string]Argument, error)
- func (c *VersionCommand) Run(args []string) int
- func (c *VersionCommand) Synopsis() string
Constants ¶
const (
// EnvCLINoColor is an env var that toggles colored UI output.
EnvCLINoColor = `NO_COLOR`
)
Variables ¶
This section is empty.
Functions ¶
func ArgumentAsString ¶
func CommandErrorText ¶
func CommandErrorText(cmd NamedCommand) string
CommandErrorText is used to easily render the same messaging across commads when an error is printed.
func CommandHelp ¶
func Commands ¶
func Commands(metaPtr *Meta, agentUi cli.Ui, commands CommandFunc) map[string]cli.CommandFactory
Commands returns the mapping of CLI commands. The meta parameter lets you set meta options for all commands.
func ExampleString ¶
func FlagString ¶
func GeneralOptionsUsage ¶
generalOptionsUsage returns the help string for the global options.
func MergeAutocompleteFlags ¶
MergeAutocompleteFlags is used to join multiple flag completion sets.
func ParseArguments ¶
Types ¶
type Argument ¶
type Argument struct {
Name string
Optional bool
Type ArgumentType
Value interface{}
HasValue bool
}
func (Argument) StringValue ¶
type ArgumentType ¶
type ArgumentType uint
ArgumentType is an enum to define what arguments are present
const ( ArgumentString ArgumentType = 0 ArgumentInt ArgumentType = 1 << iota ArgumentBool ArgumentType = 2 << iota ArgumentList ArgumentType = 3 << iota )
type CommandFunc ¶
type CommandFunc func(meta Meta) map[string]cli.CommandFactory
type FlagSetFlags ¶
type FlagSetFlags uint
FlagSetFlags is an enum to define what flags are present in the default FlagSet returned by Meta.FlagSet.
const ( FlagSetNone FlagSetFlags = 0 FlagSetClient FlagSetFlags = 1 << iota FlagSetDefault = FlagSetClient )
type GlobalFlagCommand ¶ added in v0.2.0
type Meta ¶
Meta contains the meta-options and functionality that nearly every command inherits.
func (*Meta) AutocompleteFlags ¶
func (m *Meta) AutocompleteFlags(fs FlagSetFlags) complete.Flags
AutocompleteFlags returns a set of flag completions for the given flag set.
func (*Meta) Colorize ¶
func (m *Meta) Colorize() *colorstring.Colorize
func (*Meta) FlagSet ¶
func (m *Meta) FlagSet(n string, fs FlagSetFlags) *flag.FlagSet
FlagSet returns a FlagSet with the common flags that every command implements. The exact behavior of FlagSet can be configured using the flags as the second parameter, for example to disable server settings on the commands that don't talk to a server.
type NamedCommand ¶
type NamedCommand interface {
Name() string
}
NamedCommand is a interface to denote a commmand's name.
type VersionCommand ¶
type VersionCommand struct {
Meta
}
func (*VersionCommand) Arguments ¶
func (c *VersionCommand) Arguments() []Argument
func (*VersionCommand) AutocompleteArgs ¶
func (c *VersionCommand) AutocompleteArgs() complete.Predictor
func (*VersionCommand) AutocompleteFlags ¶
func (c *VersionCommand) AutocompleteFlags() complete.Flags
func (*VersionCommand) Examples ¶
func (c *VersionCommand) Examples() map[string]string
func (*VersionCommand) FlagSet ¶
func (c *VersionCommand) FlagSet() *flag.FlagSet
func (*VersionCommand) Help ¶
func (c *VersionCommand) Help() string
func (*VersionCommand) Name ¶
func (c *VersionCommand) Name() string
func (*VersionCommand) ParsedArguments ¶
func (c *VersionCommand) ParsedArguments(args []string) (map[string]Argument, error)
func (*VersionCommand) Run ¶
func (c *VersionCommand) Run(args []string) int
func (*VersionCommand) Synopsis ¶
func (c *VersionCommand) Synopsis() string