Documentation
¶
Index ¶
- Constants
- Variables
- func AutocompleteAppAction(c *Context) error
- func CurrentBinaryInvocation() (string, error)
- func CurrentBinaryName() string
- func CurrentBinaryPath() (string, error)
- func ExpandHome(path string) string
- func FormatErrorChain(buf *bytes.Buffer, err error, trimPaths bool) bool
- func GuessShell() string
- func HandleError(err error)
- func HandleExitCoder(err error)
- func Hide() bool
- func IsAutocomplete(c *Command) bool
- func IsGoRun() bool
- func IsHelp(c *Context) bool
- func ShowAppHelp(c *Context) error
- func ShowAppHelpAction(c *Context) error
- func ShowCommandHelp(ctx *Context, command string) error
- func ShowVersion(c *Context)
- func VerbosityFlag(name, alias, shortAlias string) *verbosityFlag
- func WrapPanic(msg interface{}) error
- type ActionFunc
- type AfterFunc
- type Alias
- type Application
- func (a *Application) BestCommand(name string) *Command
- func (a *Application) Category(name string) *CommandCategory
- func (a *Application) Command(name string) *Command
- func (a *Application) Run(arguments []string) (err error)
- func (a *Application) VisibleCategories() []CommandCategory
- func (a *Application) VisibleCommands() []*Command
- func (a *Application) VisibleFlags() []Flag
- type Arg
- type ArgDefinition
- type Args
- type BeforeFunc
- type BoolFlag
- type Command
- func (c *Command) Arguments() ArgDefinition
- func (c *Command) FullName() string
- func (c *Command) HasName(name string, exact bool) bool
- func (c *Command) Names() []string
- func (c *Command) PredictArgs(ctx *Context, a complete.Args) []string
- func (c *Command) PreferredName() string
- func (c *Command) Run(ctx *Context) (err error)
- func (c *Command) VisibleFlags() []Flag
- type CommandCategories
- type CommandCategory
- type CommandNotFoundError
- type CommandNotFoundFunc
- type Context
- func (c *Context) Args() Args
- func (c *Context) Bool(name string) bool
- func (c *Context) CurrentBinaryInvocation() string
- func (c *Context) CurrentBinaryPath() string
- func (c *Context) Duration(name string) time.Duration
- func (c *Context) Float64(name string) float64
- func (c *Context) Float64Slice(name string) []float64
- func (c *Context) Generic(name string) interface{}
- func (c *Context) HasFlag(name string) bool
- func (c *Context) Int(name string) int
- func (c *Context) Int64(name string) int64
- func (c *Context) Int64Slice(name string) []int64
- func (c *Context) IntSlice(name string) []int
- func (c *Context) IsSet(name string) bool
- func (c *Context) Lineage() []*Context
- func (c *Context) NArg() int
- func (c *Context) Set(name, value string) error
- func (c *Context) String(name string) string
- func (c *Context) StringMap(name string) map[string]string
- func (c *Context) StringSlice(name string) []string
- func (c *Context) Uint(name string) uint
- func (c *Context) Uint64(name string) uint64
- type ContextPredictor
- type DescriptionFunc
- type DurationFlag
- type ExitCoder
- type Flag
- type FlagParsingMode
- type FlagStringFunc
- type FlagsByName
- type Float64Flag
- type Float64Slice
- type Float64SliceFlag
- type Generic
- type GenericFlag
- type IncorrectUsageError
- type Int64Flag
- type Int64Slice
- type Int64SliceFlag
- type IntFlag
- type IntSlice
- type IntSliceFlag
- type MultiError
- type Predictor
- type Serializeder
- type ShellCompleteFunc
- type StringFlag
- type StringMap
- type StringMapFlag
- type StringSlice
- type StringSliceFlag
- type Uint64Flag
- type UintFlag
- type WrappedPanic
Examples ¶
Constants ¶
const SupportsAutocomplete = true
Variables ¶
var ( NoInteractionFlag = &BoolFlag{ Name: "no-interaction", Usage: "Disable all interactions", } NoAnsiFlag = &BoolFlag{ Name: "no-ansi", Usage: "Disable ANSI output", } AnsiFlag = &BoolFlag{ Name: "ansi", Usage: "Force ANSI output", } )
var AppHelpTemplate = `` /* 687-byte string literal not displayed */
AppHelpTemplate is the text template for the Default help topic. cli.go uses text/template to render templates. You can render custom help text by setting this variable.
var CategoryHelpTemplate = `` /* 652-byte string literal not displayed */
CategoryHelpTemplate is the text template for the category help topic. cli.go uses text/template to render templates. You can render custom help text by setting this variable.
var CommandHelpTemplate = `` /* 393-byte string literal not displayed */
CommandHelpTemplate is the text template for the command help topic. cli.go uses text/template to render templates. You can render custom help text by setting this variable.
var CompletionTemplates embed.FS
CompletionTemplates holds our shell completions templates.
var HelpFlag = &BoolFlag{ Name: "help", Aliases: []string{"h"}, Usage: "Show help", }
HelpFlag prints the help for all commands and subcommands. Set to nil to disable the flag.
var HelpPrinter helpPrinter = printHelp
HelpPrinter is a function that writes the help output. If not set a default is used. The function signature is: func(w io.Writer, templ string, data interface{})
var LogLevelFlag = VerbosityFlag("log-level", "verbose", "v")
var OsExiter = os.Exit
OsExiter is the function used when the app exits. If not set defaults to os.Exit.
var QuietFlag = newQuietFlag("quiet", "q")
var VersionFlag = &BoolFlag{
Name: "V",
Usage: "Print the version",
}
VersionFlag prints the version for the application
var VersionPrinter = printVersion
VersionPrinter prints the version for the App
Functions ¶
func AutocompleteAppAction ¶ added in v1.1.0
func CurrentBinaryInvocation ¶ added in v1.1.0
func CurrentBinaryName ¶
func CurrentBinaryName() string
func CurrentBinaryPath ¶
func ExpandHome ¶
func GuessShell ¶ added in v1.1.4
func GuessShell() string
func HandleError ¶
func HandleError(err error)
func HandleExitCoder ¶
func HandleExitCoder(err error)
HandleExitCoder checks if the error fulfills the ExitCoder interface, and if so prints the error to stderr (if it is non-empty) and calls OsExiter with the given exit code. If the given error is a MultiError, then this func is called on all members of the Errors slice.
func IsAutocomplete ¶ added in v1.1.0
func ShowAppHelp ¶
ShowAppHelp is an action that displays the help.
func ShowAppHelpAction ¶
ShowAppHelpAction is an action that displays the global help or for the specified command.
func ShowCommandHelp ¶
ShowCommandHelp prints help for the given command
func VerbosityFlag ¶
func VerbosityFlag(name, alias, shortAlias string) *verbosityFlag
Types ¶
type ActionFunc ¶
ActionFunc is the action to execute when no subcommands are specified
type AfterFunc ¶
AfterFunc is an action to execute after any subcommands are run, but after the subcommand has finished it is run even if Action() panics
type Application ¶
type Application struct { // The name of the program. Defaults to filepath.Base(os.Executable()) Name string // Full name of command for help, defaults to Name HelpName string // Description of the program. Usage string // Version of the program Version string // Channel of the program (dev, beta, stable, ...) Channel string // Description of the program Description string // List of commands to execute Commands []*Command // List of flags to parse Flags []Flag // Prefix used to automatically find flag in environment FlagEnvPrefix []string // Categories contains the categorized commands and is populated on app startup Categories CommandCategories // An action to execute before any subcommands are run, but after the context is ready // If a non-nil error is returned, no subcommands are run Before BeforeFunc // An action to execute after any subcommands are run, but after the subcommand has finished // It is run even if Action() panics After AfterFunc // The action to execute when no subcommands are specified Action ActionFunc // Build date BuildDate string // Copyright of the binary if any Copyright string // Writer writer to write output to Writer io.Writer // ErrWriter writes error output ErrWriter io.Writer // contains filtered or unexported fields }
Application is the main structure of a cli application.
func (*Application) BestCommand ¶ added in v1.0.3
func (a *Application) BestCommand(name string) *Command
BestCommand returns the named command on App or a command fuzzy matching if there is only one. Returns nil if the command does not exist of if the fuzzy matching find more than one.
func (*Application) Category ¶
func (a *Application) Category(name string) *CommandCategory
Category returns the named CommandCategory on App. Returns nil if the category does not exist
func (*Application) Command ¶
func (a *Application) Command(name string) *Command
Command returns the named command on App. Returns nil if the command does not exist
func (*Application) Run ¶
func (a *Application) Run(arguments []string) (err error)
Run is the entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination
Example ¶
// set args for examples sake os.Args = []string{"greet", "--name", "Jeremy"} app := &Application{ Writer: os.Stdout, ErrWriter: os.Stderr, Name: "greet", Flags: []Flag{ &StringFlag{Name: "name", DefaultValue: "bob", Usage: "a name to say"}, }, Action: func(c *Context) error { fmt.Printf("Hello %v\n", c.String("name")) return nil }, } app.Run(os.Args)
Output: Hello Jeremy
Example (CommandHelp) ¶
// set args for examples sake os.Args = []string{"greet", "help", "describeit"} app := &Application{ Writer: os.Stdout, ErrWriter: os.Stderr, Name: "greet", HelpName: "greet", Flags: []Flag{ &StringFlag{Name: "name", DefaultValue: "bob", Usage: "a name to say"}, }, Commands: []*Command{ { Name: "describeit", Aliases: []*Alias{{Name: "d"}}, Usage: "use it to see a description", Description: "This is how we describe describeit the function", Action: func(c *Context) error { fmt.Printf("i like to describe things") return nil }, }, }, } app.Run(os.Args)
Output: <comment>Description:</> use it to see a description <comment>Usage:</> greet describeit <comment>Help:</> This is how we describe describeit the function
Example (Quiet) ¶
// set args for examples sake os.Args = []string{"greet", "-q", "--name", "Jeremy"} app := &Application{ Writer: os.Stdout, ErrWriter: os.Stdout, Name: "greet", Flags: []Flag{ &StringFlag{Name: "name", DefaultValue: "bob", Usage: "a name to say"}, }, Action: func(c *Context) error { fmt.Fprintf(c.App.Writer, "Hello %v\n", c.String("name")) fmt.Fprintf(c.App.ErrWriter, "Byebye %v\n", c.String("name")) return nil }, } app.Run(os.Args)
Output:
Example (QuietDisabled) ¶
terminal.DefaultStdout = terminal.NewBufferedConsoleOutput(os.Stdout, os.Stdout) // set args for examples sake os.Args = []string{"greet", "--quiet=false", "--name", "Jeremy"} app := &Application{ Writer: os.Stdout, ErrWriter: os.Stdout, Name: "greet", Flags: []Flag{ &StringFlag{Name: "name", DefaultValue: "bob", Usage: "a name to say"}, }, Action: func(c *Context) error { fmt.Fprintf(c.App.Writer, "Hello %v\n", c.String("name")) fmt.Fprintf(c.App.ErrWriter, "Byebye %v\n", c.String("name")) return nil }, } app.Run(os.Args)
Output: Hello Jeremy Byebye Jeremy
func (*Application) VisibleCategories ¶
func (a *Application) VisibleCategories() []CommandCategory
VisibleCategories returns a slice of categories and commands that are Hidden=false
func (*Application) VisibleCommands ¶
func (a *Application) VisibleCommands() []*Command
VisibleCommands returns a slice of the Commands with Hidden=false
func (*Application) VisibleFlags ¶
func (a *Application) VisibleFlags() []Flag
VisibleFlags returns a slice of the Flags with Hidden=false
type ArgDefinition ¶
type ArgDefinition []*Arg
func (ArgDefinition) Usage ¶
func (def ArgDefinition) Usage() string
type Args ¶
type Args interface { // Get returns the named argument, or else a blank string Get(name string) string // Tail returns the rest of the arguments (the last "array" one) // or else an empty string slice Tail() []string // Len returns the length of the wrapped slice Len() int // Present checks if there are any arguments present Present() bool // Slice returns a copy of the internal slice Slice() []string // contains filtered or unexported methods }
type BeforeFunc ¶
BeforeFunc is an action to execute before any subcommands are run, but after the context is ready if a non-nil error is returned, no subcommands are run
type BoolFlag ¶
type BoolFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultValue bool DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, bool) error Destination *bool }
BoolFlag is a flag with type bool
func (*BoolFlag) PredictArgs ¶ added in v1.1.0
type Command ¶
type Command struct { // The name of the command Name string // A list of aliases for the command Aliases []*Alias // A short description of the usage of this command Usage string // A longer explanation of how the command works Description string // or a function responsible to render the description DescriptionFunc DescriptionFunc // The category the command is part of Category string // The function to call when checking for shell command completions ShellComplete ShellCompleteFunc // An action to execute before any sub-subcommands are run, but after the context is ready // If a non-nil error is returned, no sub-subcommands are run Before BeforeFunc // An action to execute after any subcommands are run, but after the subcommand has finished // It is run even if Action() panics After AfterFunc // The function to call when this command is invoked Action ActionFunc // List of flags to parse Flags []Flag // List of args to parse Args ArgDefinition // Treat all flags as normal arguments if true FlagParsing FlagParsingMode // Boolean to hide this command from help Hidden func() bool // Full name of command for help, defaults to full command name, including parent commands. HelpName string // The name used on the CLI by the user UserName string }
Command is a subcommand for a console.App.
func (*Command) Arguments ¶
func (c *Command) Arguments() ArgDefinition
Arguments returns a slice of the Arguments
func (*Command) FullName ¶
FullName returns the full name of the command. For subcommands this ensures that parent commands are part of the command path
func (*Command) PredictArgs ¶ added in v1.1.0
func (*Command) PreferredName ¶
func (*Command) Run ¶
Run invokes the command given the context, parses ctx.Args() to generate command-specific flags
func (*Command) VisibleFlags ¶
VisibleFlags returns a slice of the Flags with Hidden=false
type CommandCategories ¶
type CommandCategories interface { // AddCommand adds a command to a category, creating a new category if necessary. AddCommand(category string, command *Command) // Categories returns a copy of the category slice Categories() []CommandCategory }
type CommandCategory ¶
type CommandCategory interface { // Name returns the category name string Name() string // VisibleCommands returns a slice of the Commands with Hidden=false VisibleCommands() []*Command }
CommandCategory is a category containing commands.
type CommandNotFoundError ¶
type CommandNotFoundError struct {
// contains filtered or unexported fields
}
func (*CommandNotFoundError) Error ¶
func (e *CommandNotFoundError) Error() string
func (*CommandNotFoundError) ExitCode ¶
func (e *CommandNotFoundError) ExitCode() int
func (*CommandNotFoundError) GetSeverity ¶
func (e *CommandNotFoundError) GetSeverity() zerolog.Level
type CommandNotFoundFunc ¶
CommandNotFoundFunc is executed if the proper command cannot be found
type Context ¶
type Context struct { App *Application Command *Command // contains filtered or unexported fields }
Context is a type that is passed through to each Handler action in a cli application. Context can be used to retrieve context-specific args and parsed command-line options.
func NewContext ¶
func NewContext(app *Application, set *flag.FlagSet, parentCtx *Context) *Context
NewContext creates a new context. For use in when invoking an App or Command action.
func (*Context) CurrentBinaryInvocation ¶ added in v1.1.0
func (*Context) CurrentBinaryPath ¶ added in v1.1.0
func (*Context) Duration ¶
Duration looks up the value of a local DurationFlag, returns 0 if not found
func (*Context) Float64Slice ¶
Float64Slice looks up the value of a local Float64SliceFlag, returns nil if not found
func (*Context) Generic ¶
Generic looks up the value of a local GenericFlag, returns nil if not found
func (*Context) HasFlag ¶
HasFlag determines if a flag is defined in this context and all of its parent contexts.
func (*Context) Int64Slice ¶
Int64Slice looks up the value of a local Int64SliceFlag, returns nil if not found
func (*Context) IntSlice ¶
IntSlice looks up the value of a local IntSliceFlag, returns nil if not found
func (*Context) Lineage ¶
Lineage returns *this* context and all of its ancestor contexts in order from child to parent
func (*Context) StringMap ¶
StringMap looks up the value of a local StringMapFlag, returns nil if not found
func (*Context) StringSlice ¶
StringSlice looks up the value of a local StringSliceFlag, returns nil if not found
type ContextPredictor ¶ added in v1.1.0
type ContextPredictor struct {
// contains filtered or unexported fields
}
ContextPredictor determines what terms can follow a command or a flag It is used for autocompletion, given the last word in the already completed command line, what words can complete it.
type DescriptionFunc ¶ added in v1.1.0
type DescriptionFunc func(*Command, *Application) string
DescriptionFunc is used by the help generation to display a description when its computation is intensive or needs runtime information
type DurationFlag ¶
type DurationFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultValue time.Duration DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, time.Duration) error Destination *time.Duration }
DurationFlag is a flag with type time.Duration (see https://golang.org/pkg/time/#ParseDuration)
func (*DurationFlag) Apply ¶
func (f *DurationFlag) Apply(set *flag.FlagSet)
Apply populates the flag given the flag set and environment
func (*DurationFlag) Names ¶
func (f *DurationFlag) Names() []string
Names returns the names of the flag
func (*DurationFlag) PredictArgs ¶ added in v1.1.0
func (f *DurationFlag) PredictArgs(c *Context, a complete.Args) []string
func (*DurationFlag) String ¶
func (f *DurationFlag) String() string
String returns a readable representation of this value (for usage defaults)
func (*DurationFlag) Validate ¶
func (f *DurationFlag) Validate(c *Context) error
type Flag ¶
type Flag interface { fmt.Stringer PredictArgs(*Context, complete.Args) []string Validate(*Context) error // Apply Flag settings to the given flag set Apply(*flag.FlagSet) Names() []string }
Flag is a common interface related to parsing flags in cli. For more advanced flag parsing techniques, it is recommended that this interface be implemented.
type FlagParsingMode ¶
type FlagParsingMode int
FlagParsingMode defines how arguments and flags parsing is done. Three different values: FlagParsingNormal, FlagParsingSkipped and FlagParsingSkippedAfterFirstArg.
const ( // FlagParsingNormal sets parsing to a normal mode, complete parsing of all // flags found after command name FlagParsingNormal FlagParsingMode = iota // FlagParsingSkipped sets parsing to a mode where parsing stops just after // the command name. FlagParsingSkipped // FlagParsingSkippedAfterFirstArg sets parsing to a hybrid mode where parsing continues // after the command name until an argument is found. // This for example allows usage like `blackfire -v=4 run --samples=2 php foo.php` FlagParsingSkippedAfterFirstArg )
func (FlagParsingMode) IsPostfix ¶
func (mode FlagParsingMode) IsPostfix() bool
func (FlagParsingMode) IsPrefix ¶
func (mode FlagParsingMode) IsPrefix() bool
type FlagStringFunc ¶
FlagStringFunc is used by the help generation to display a flag, which is expected to be a single line.
var FlagStringer FlagStringFunc = stringifyFlag
FlagStringer converts a flag definition to a string. This is used by help to display a flag.
type FlagsByName ¶
type FlagsByName []Flag
FlagsByName is a slice of Flag.
func (FlagsByName) Len ¶
func (f FlagsByName) Len() int
func (FlagsByName) Less ¶
func (f FlagsByName) Less(i, j int) bool
func (FlagsByName) Swap ¶
func (f FlagsByName) Swap(i, j int)
type Float64Flag ¶
type Float64Flag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultValue float64 DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, float64) error Destination *float64 }
Float64Flag is a flag with type float64
func (*Float64Flag) Apply ¶
func (f *Float64Flag) Apply(set *flag.FlagSet)
Apply populates the flag given the flag set and environment
func (*Float64Flag) Names ¶
func (f *Float64Flag) Names() []string
Names returns the names of the flag
func (*Float64Flag) PredictArgs ¶ added in v1.1.0
func (f *Float64Flag) PredictArgs(c *Context, a complete.Args) []string
func (*Float64Flag) String ¶
func (f *Float64Flag) String() string
String returns a readable representation of this value (for usage defaults)
func (*Float64Flag) Validate ¶
func (f *Float64Flag) Validate(c *Context) error
type Float64Slice ¶
type Float64Slice struct {
// contains filtered or unexported fields
}
Float64Slice is an opaque type for []float64 to satisfy flag.Value
func NewFloat64Slice ¶
func NewFloat64Slice(defaults ...float64) *Float64Slice
NewFloat64Slice makes a *Float64Slice with default values
func (*Float64Slice) Serialized ¶
func (f *Float64Slice) Serialized() string
Serialized allows Float64Slice to fulfill Serializeder
func (*Float64Slice) Set ¶
func (f *Float64Slice) Set(value string) error
Set parses the value into a float64 and appends it to the list of values
func (*Float64Slice) String ¶
func (f *Float64Slice) String() string
String returns a readable representation of this value (for usage defaults)
func (*Float64Slice) Value ¶
func (f *Float64Slice) Value() []float64
Value returns the slice of float64s set by this flag
type Float64SliceFlag ¶
type Float64SliceFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, []float64) error Destination *Float64Slice }
Float64SliceFlag is a flag with type *Float64Slice
func (*Float64SliceFlag) Apply ¶
func (f *Float64SliceFlag) Apply(set *flag.FlagSet)
Apply populates the flag given the flag set and environment
func (*Float64SliceFlag) Names ¶
func (f *Float64SliceFlag) Names() []string
Names returns the names of the flag
func (*Float64SliceFlag) PredictArgs ¶ added in v1.1.0
func (f *Float64SliceFlag) PredictArgs(c *Context, a complete.Args) []string
func (*Float64SliceFlag) String ¶
func (f *Float64SliceFlag) String() string
String returns a readable representation of this value (for usage defaults)
func (*Float64SliceFlag) Validate ¶
func (f *Float64SliceFlag) Validate(c *Context) error
type GenericFlag ¶
type GenericFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, interface{}) error Destination Generic }
GenericFlag is a flag with type Generic
func (*GenericFlag) Apply ¶
func (f *GenericFlag) Apply(set *flag.FlagSet)
Apply takes the flagset and calls Set on the generic flag with the value provided by the user for parsing by the flag
func (*GenericFlag) Names ¶
func (f *GenericFlag) Names() []string
Names returns the names of the flag
func (*GenericFlag) PredictArgs ¶ added in v1.1.0
func (f *GenericFlag) PredictArgs(c *Context, a complete.Args) []string
func (*GenericFlag) String ¶
func (f *GenericFlag) String() string
String returns a readable representation of this value (for usage defaults)
func (*GenericFlag) Validate ¶
func (f *GenericFlag) Validate(c *Context) error
type IncorrectUsageError ¶
type IncorrectUsageError struct {
ParentError error
}
func (IncorrectUsageError) Cause ¶
func (e IncorrectUsageError) Cause() error
func (IncorrectUsageError) Error ¶
func (e IncorrectUsageError) Error() string
type Int64Flag ¶
type Int64Flag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultValue int64 DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, int64) error Destination *int64 }
Int64Flag is a flag with type int64
func (*Int64Flag) PredictArgs ¶ added in v1.1.0
type Int64Slice ¶
type Int64Slice struct {
// contains filtered or unexported fields
}
Int64Slice is an opaque type for []int to satisfy flag.Value
func NewInt64Slice ¶
func NewInt64Slice(defaults ...int64) *Int64Slice
NewInt64Slice makes an *Int64Slice with default values
func (*Int64Slice) Serialized ¶
func (f *Int64Slice) Serialized() string
Serialized allows Int64Slice to fulfill Serializeder
func (*Int64Slice) Set ¶
func (f *Int64Slice) Set(value string) error
Set parses the value into an integer and appends it to the list of values
func (*Int64Slice) String ¶
func (f *Int64Slice) String() string
String returns a readable representation of this value (for usage defaults)
func (*Int64Slice) Value ¶
func (f *Int64Slice) Value() []int64
Value returns the slice of ints set by this flag
type Int64SliceFlag ¶
type Int64SliceFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, []int64) error Destination *Int64Slice }
Int64SliceFlag is a flag with type *Int64Slice
func (*Int64SliceFlag) Apply ¶
func (f *Int64SliceFlag) Apply(set *flag.FlagSet)
Apply populates the flag given the flag set and environment
func (*Int64SliceFlag) Names ¶
func (f *Int64SliceFlag) Names() []string
Names returns the names of the flag
func (*Int64SliceFlag) PredictArgs ¶ added in v1.1.0
func (f *Int64SliceFlag) PredictArgs(c *Context, a complete.Args) []string
func (*Int64SliceFlag) String ¶
func (f *Int64SliceFlag) String() string
String returns a readable representation of this value (for usage defaults)
func (*Int64SliceFlag) Validate ¶
func (f *Int64SliceFlag) Validate(c *Context) error
type IntFlag ¶
type IntFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultValue int DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, int) error Destination *int }
IntFlag is a flag with type int
func (*IntFlag) PredictArgs ¶ added in v1.1.0
type IntSlice ¶
type IntSlice struct {
// contains filtered or unexported fields
}
IntSlice wraps an []int to satisfy flag.Value
func NewIntSlice ¶
NewIntSlice makes an *IntSlice with default values
func (*IntSlice) Serialized ¶
Serialized allows IntSlice to fulfill Serializeder
type IntSliceFlag ¶
type IntSliceFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, []int) error Destination *IntSlice }
IntSliceFlag is a flag with type *IntSlice
func (*IntSliceFlag) Apply ¶
func (f *IntSliceFlag) Apply(set *flag.FlagSet)
Apply populates the flag given the flag set and environment
func (*IntSliceFlag) Names ¶
func (f *IntSliceFlag) Names() []string
Names returns the names of the flag
func (*IntSliceFlag) PredictArgs ¶ added in v1.1.0
func (f *IntSliceFlag) PredictArgs(c *Context, a complete.Args) []string
func (*IntSliceFlag) String ¶
func (f *IntSliceFlag) String() string
String returns a readable representation of this value (for usage defaults)
func (*IntSliceFlag) Validate ¶
func (f *IntSliceFlag) Validate(c *Context) error
type MultiError ¶
MultiError is an error that wraps multiple errors.
type Serializeder ¶
type Serializeder interface {
Serialized() string
}
Serializeder is used to circumvent the limitations of flag.FlagSet.Set
type ShellCompleteFunc ¶ added in v1.1.0
ShellCompleteFunc is an action to execute when the shell completion flag is set
type StringFlag ¶
type StringFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultValue string DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, string) error Destination *string }
StringFlag is a flag with type string
func (*StringFlag) Apply ¶
func (f *StringFlag) Apply(set *flag.FlagSet)
Apply populates the flag given the flag set and environment
func (*StringFlag) Names ¶
func (f *StringFlag) Names() []string
Names returns the names of the flag
func (*StringFlag) PredictArgs ¶ added in v1.1.0
func (f *StringFlag) PredictArgs(c *Context, a complete.Args) []string
func (*StringFlag) String ¶
func (f *StringFlag) String() string
String returns a readable representation of this value (for usage defaults)
func (*StringFlag) Validate ¶
func (f *StringFlag) Validate(c *Context) error
type StringMap ¶
type StringMap struct {
// contains filtered or unexported fields
}
StringMap wraps a map[string]string to satisfy flag.Value
func NewStringMap ¶
NewStringMap creates a *StringMap with default values
func (*StringMap) Serialized ¶
Serialized allows StringSlice to fulfill Serializeder
type StringMapFlag ¶
type StringMapFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, map[string]string) error Destination *StringMap }
StringMapFlag is a flag with type *StringMap
func (*StringMapFlag) Apply ¶
func (f *StringMapFlag) Apply(set *flag.FlagSet)
Apply populates the flag given the flag set and environment
func (*StringMapFlag) Names ¶
func (f *StringMapFlag) Names() []string
Names returns the names of the flag
func (*StringMapFlag) PredictArgs ¶ added in v1.1.0
func (f *StringMapFlag) PredictArgs(c *Context, a complete.Args) []string
func (*StringMapFlag) String ¶
func (f *StringMapFlag) String() string
String returns a readable representation of this value (for usage defaults)
func (*StringMapFlag) Validate ¶
func (f *StringMapFlag) Validate(c *Context) error
type StringSlice ¶
type StringSlice struct {
// contains filtered or unexported fields
}
StringSlice wraps a []string to satisfy flag.Value
func NewStringSlice ¶
func NewStringSlice(defaults ...string) *StringSlice
NewStringSlice creates a *StringSlice with default values
func (*StringSlice) Serialized ¶
func (f *StringSlice) Serialized() string
Serialized allows StringSlice to fulfill Serializeder
func (*StringSlice) Set ¶
func (f *StringSlice) Set(value string) error
Set appends the string value to the list of values
func (*StringSlice) String ¶
func (f *StringSlice) String() string
String returns a readable representation of this value (for usage defaults)
func (*StringSlice) Value ¶
func (f *StringSlice) Value() []string
Value returns the slice of strings set by this flag
type StringSliceFlag ¶
type StringSliceFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, []string) error Destination *StringSlice }
StringSliceFlag is a flag with type *StringSlice
func (*StringSliceFlag) Apply ¶
func (f *StringSliceFlag) Apply(set *flag.FlagSet)
Apply populates the flag given the flag set and environment
func (*StringSliceFlag) Names ¶
func (f *StringSliceFlag) Names() []string
Names returns the names of the flag
func (*StringSliceFlag) PredictArgs ¶ added in v1.1.0
func (f *StringSliceFlag) PredictArgs(c *Context, a complete.Args) []string
func (*StringSliceFlag) String ¶
func (f *StringSliceFlag) String() string
String returns a readable representation of this value (for usage defaults)
func (*StringSliceFlag) Validate ¶
func (f *StringSliceFlag) Validate(c *Context) error
type Uint64Flag ¶
type Uint64Flag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultValue uint64 DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, uint64) error Destination *uint64 }
Uint64Flag is a flag with type uint64
func (*Uint64Flag) Apply ¶
func (f *Uint64Flag) Apply(set *flag.FlagSet)
Apply populates the flag given the flag set and environment
func (*Uint64Flag) Names ¶
func (f *Uint64Flag) Names() []string
Names returns the names of the flag
func (*Uint64Flag) PredictArgs ¶ added in v1.1.0
func (f *Uint64Flag) PredictArgs(c *Context, a complete.Args) []string
func (*Uint64Flag) String ¶
func (f *Uint64Flag) String() string
String returns a readable representation of this value (for usage defaults)
func (*Uint64Flag) Validate ¶
func (f *Uint64Flag) Validate(c *Context) error
type UintFlag ¶
type UintFlag struct { Name string Aliases []string Usage string EnvVars []string Hidden bool DefaultValue uint DefaultText string Required bool ArgsPredictor func(*Context, complete.Args) []string Validator func(*Context, uint) error Destination *uint }
UintFlag is a flag with type uint
func (*UintFlag) PredictArgs ¶ added in v1.1.0
type WrappedPanic ¶
type WrappedPanic struct {
// contains filtered or unexported fields
}
func (WrappedPanic) Cause ¶
func (p WrappedPanic) Cause() error
func (WrappedPanic) Error ¶
func (p WrappedPanic) Error() string
func (WrappedPanic) StackTrace ¶
func (p WrappedPanic) StackTrace() errors.StackTrace