Documentation ¶
Index ¶
- Constants
- func ArgumentAsString(arguments []Argument) string
- func ArgumentsString(arguments []Argument) string
- func CommandErrorText(cmd NamedCommand) string
- func CommandHelp(c Command) string
- func Commands(ctx context.Context, metaPtr *Meta, commandsFunc CommandFunc) map[string]cli.CommandFactory
- func ExampleString(examples map[string]string) string
- func FlagString(flags *flag.FlagSet) string
- func MergeAutocompleteFlags(flags ...complete.Flags) complete.Flags
- func ParseArguments(args []string, arguments []Argument) (map[string]Argument, error)
- func SetupEnv(args []string)
- type Argument
- type ArgumentType
- type Command
- type CommandFunc
- type FlagSetFlags
- type GlobalFlagCommand
- type HumanWriter
- 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
- type ZerologUi
- func (u *ZerologUi) Ask(query string) (string, error)
- func (u *ZerologUi) AskSecret(query string) (string, error)
- func (u *ZerologUi) Error(message string)
- func (u *ZerologUi) Field(field string, value interface{}) *ZerologUi
- func (u *ZerologUi) Fields(newFields map[string]interface{}) *ZerologUi
- func (u *ZerologUi) Info(message string)
- func (u *ZerologUi) LogHeader1(message string)
- func (u *ZerologUi) LogHeader2(message string)
- func (u *ZerologUi) Output(message string)
- func (u *ZerologUi) Warn(message 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 ArgumentsString ¶ added in v0.3.0
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(ctx context.Context, metaPtr *Meta, commandsFunc 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 MergeAutocompleteFlags ¶
MergeAutocompleteFlags is used to join multiple flag completion sets.
func ParseArguments ¶
Types ¶
type Argument ¶
type Argument struct { Name string Description 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 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 HumanWriter ¶ added in v0.6.0
type HumanWriter struct { // Out is the output destination. Out io.Writer // NoColor disables the colorized output. NoColor bool // TimeFormat specifies the format for timestamp in output. TimeFormat string // PartsOrder defines the order of parts in output. PartsOrder []string // PartsExclude defines parts to not display in output. PartsExclude []string FormatTimestamp zerolog.Formatter FormatLevel zerolog.Formatter FormatCaller zerolog.Formatter FormatMessage zerolog.Formatter FormatFieldName zerolog.Formatter FormatFieldValue zerolog.Formatter FormatErrFieldName zerolog.Formatter FormatErrFieldValue zerolog.Formatter }
HumanWriter parses the JSON input and writes it in an (optionally) colorized, human-friendly format to Out.
func NewHumanWriter ¶ added in v0.6.0
func NewHumanWriter(options ...func(w *HumanWriter)) HumanWriter
NewHumanWriter creates and initializes a new HumanWriter.
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
type ZerologUi ¶ added in v0.6.0
type ZerologUi struct { StderrLogger zerolog.Logger StdoutLogger zerolog.Logger OriginalFields map[string]interface{} Ui cli.Ui OutputIndentField bool }