Documentation ¶
Index ¶
- Constants
- func Copyright(name string) string
- func EnvOf(items ...string) string
- func FlagFormat(flag Flag) string
- type ActionFunc
- type AfterFunc
- type App
- type Author
- type BackOffProvider
- type BackOffStrategy
- type BeforeFunc
- type BoolFlag
- type Command
- type CommandCategory
- type CommandNotFoundFunc
- type CommandsByName
- type Context
- func (ctx *Context) Bool(name string) bool
- func (ctx *Context) Duration(name string) time.Duration
- func (ctx *Context) EnvVars() map[string]string
- func (ctx *Context) Float32(name string) float32
- func (ctx *Context) Float64(name string) float64
- func (ctx *Context) Get(name string) interface{}
- func (ctx *Context) GlobalBool(name string) bool
- func (ctx *Context) GlobalDuration(name string) time.Duration
- func (ctx *Context) GlobalFloat32(name string) float32
- func (ctx *Context) GlobalFloat64(name string) float64
- func (ctx *Context) GlobalGet(name string) interface{}
- func (ctx *Context) GlobalHardwareAddr(name string) net.HardwareAddr
- func (ctx *Context) GlobalIP(name string) net.IP
- func (ctx *Context) GlobalInt(name string) int
- func (ctx *Context) GlobalInt64(name string) int64
- func (ctx *Context) GlobalString(name string) string
- func (ctx *Context) GlobalStringSlice(name string) []string
- func (ctx *Context) GlobalTime(name string) time.Time
- func (ctx *Context) GlobalUInt(name string) uint
- func (ctx *Context) GlobalUInt64(name string) uint64
- func (ctx *Context) GlobalURL(name string) *url.URL
- func (ctx *Context) HardwareAddr(name string) net.HardwareAddr
- func (ctx *Context) IP(name string) net.IP
- func (ctx *Context) Int(name string) int
- func (ctx *Context) Int64(name string) int64
- func (ctx *Context) String(name string) string
- func (ctx *Context) StringSlice(name string) []string
- func (ctx *Context) Time(name string) time.Time
- func (ctx *Context) UInt(name string) uint
- func (ctx *Context) UInt64(name string) uint64
- func (ctx *Context) URL(name string) *url.URL
- type DurationFlag
- type EnvProvider
- type ExitCoder
- type ExitError
- type ExitErrorCollector
- type ExitErrorHandlerFunc
- type ExitFunc
- type Flag
- type FlagAccessor
- func (f *FlagAccessor) EnvVar() string
- func (f *FlagAccessor) Get() interface{}
- func (f *FlagAccessor) Hidden() bool
- func (f *FlagAccessor) IsBoolFlag() bool
- func (f *FlagAccessor) IsPathFlag() bool
- func (f *FlagAccessor) Name() string
- func (f *FlagAccessor) Path() string
- func (f *FlagAccessor) ReadFrom(r io.Reader) (int64, error)
- func (f *FlagAccessor) Reset() error
- func (f *FlagAccessor) Set(value string) error
- func (f *FlagAccessor) String() string
- func (f *FlagAccessor) Usage() string
- func (f *FlagAccessor) Validate(ctx *Context) error
- func (f *FlagAccessor) Value() interface{}
- type FlagProvider
- type FlagsByName
- type Float32Flag
- type Float64Flag
- type HardwareAddrFlag
- type IPFlag
- type Int64Flag
- type IntFlag
- type JSONFlag
- type Map
- type PathProvider
- type Provider
- type SignalFunc
- type StringFlag
- type StringSliceFlag
- type TimeFlag
- type UInt64Flag
- type UIntFlag
- type URLFlag
- type UsageErrorFunc
- type Validator
- type ValidatorFunc
- type XMLFlag
- type YAMLFlag
Constants ¶
const ( // ExitCodeErrorApp is the exit code on application error ExitCodeErrorApp = 1001 // ExitCodeErrorFlag is the exit code on flag error ExitCodeErrorFlag = 1002 // ExitCodeNotFoundFlag is the exit code when a flag is not found ExitCodeNotFoundFlag = 1003 // ExitCodeNotFoundCommand is the exit code when a command is not found ExitCodeNotFoundCommand = 1004 )
Variables ¶
This section is empty.
Functions ¶
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 App ¶
type App struct { // The name of the program. Defaults to path.Base(os.Args[0]) Name string // A short description of the usage of this command Usage string // Custom text to show on USAGE section of help UsageText string // A longer explanation of how the command works Description string // A short description of the arguments of this command ArgsUsage string // Compilation date Compiled time.Time // List of all authors who contributed Authors []*Author // Copyright of the binary if any Copyright string // Full name of command for help, defaults to full command name, including parent commands. HelpName string // Boolean to hide built-in help command HideHelp bool // Version of the program Version string // Boolean to hide built-in version flag and the VERSION section of help HideVersion bool // Signals are the signals that we want to handle Signals []os.Signal // List of commands to execute Commands []*Command // List of flags to parse Flags []Flag // Providers contains a list of all providers Providers []Provider // 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 // An action to execute before provider execution BeforeInit BeforeFunc // An action to execute after provider execution AfterInit AfterFunc // The action to execute when no subcommands are specified // Expects a `cli.ActionFunc` but will accept the *deprecated* signature of `func(*cli.Context) {}` Action ActionFunc // Strategy enables comman retry logic Strategy BackOffStrategy // OnSignal occurs on system signal OnSignal SignalFunc // Execute this function if a usage error occurs. OnUsageError UsageErrorFunc // OnCommandNotFound is executed if the proper command cannot be found OnCommandNotFound CommandNotFoundFunc // Execute this function to handle ExitErrors. If not provided, HandleExitCoder is provided to // function as a default, so this is optional. OnExitError ExitErrorHandlerFunc // Exit is the function used when the app exits. If not set defaults to os.Exit. Exit ExitFunc // Writer writer to write output to Writer io.Writer // ErrWriter writes error output ErrWriter io.Writer }
App is the main structure of a cli application. It is recommended that an app be created with the cli.NewApp() function
type BackOffProvider ¶
type BackOffProvider struct { Provider Provider Strategy BackOffStrategy }
BackOffProvider backoff the provider
func (*BackOffProvider) Provide ¶
func (m *BackOffProvider) Provide(ctx *Context) error
Provide parses the args
type BackOffStrategy ¶
BackOffStrategy represents the backoff strategy
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 Path string Usage string EnvVar string Value bool Hidden bool Validator Validator }
BoolFlag is a flag with type bool
func (*BoolFlag) Get ¶
func (f *BoolFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*BoolFlag) IsBoolFlag ¶
IsBoolFlag returns true if the flag is bool
type Command ¶
type Command struct { // The name of the command Name string // A list of aliases for the command Aliases []string // A short description of the usage of this command Usage string // Custom text to show on USAGE section of help UsageText string // A longer explanation of how the command works Description string // A short description of the arguments of this command ArgsUsage string // The category the command is part of Category string // Boolean to hide this command from help or completion Hidden bool // Full name of command for help, defaults to full command name, including parent commands. HelpName string // Boolean to hide built-in help command HideHelp bool // Metadata information Metadata map[string]interface{} // List of child commands Commands []*Command // Treat all flags as normal arguments if true SkipFlagParsing bool // List of flags to parse Flags []Flag // Providers contains a list of all providers Providers []Provider // 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 After AfterFunc // An action to execute before provider execution BeforeInit BeforeFunc // An action to execute after provider execution AfterInit AfterFunc // The action to execute when no subcommands are specified // Expects a cli.ActionFunc Action ActionFunc // Strategy enables comman retry logic Strategy BackOffStrategy // Execute this function if a usage error occurs. OnUsageError UsageErrorFunc // OnCommandNotFound is executed if the proper command cannot be found OnCommandNotFound CommandNotFoundFunc }
Command is a command for a cli.App.
func NewVersionCommand ¶
func NewVersionCommand() *Command
NewVersionCommand creates a version command
func (*Command) RunWithContext ¶
RunWithContext runs the command
func (*Command) VisibleCategories ¶
func (cmd *Command) VisibleCategories() []*CommandCategory
VisibleCategories returns a slice of categories and commands that are Hidden=false
func (*Command) VisibleCommands ¶
VisibleCommands returns a slice of the Commands with Hidden=false
func (*Command) VisibleFlags ¶
VisibleFlags returns a slice of the Flags with Hidden=false
type CommandCategory ¶
CommandCategory is a category containing commands.
func (*CommandCategory) VisibleCommands ¶
func (category *CommandCategory) VisibleCommands() []*Command
VisibleCommands returns a slice of the Commands with Hidden=false
type CommandNotFoundFunc ¶
OnCommandNotFoundFunc is executed if the proper command cannot be found
type CommandsByName ¶
type CommandsByName []*Command
CommandsByName is a slice of Command
func (CommandsByName) Less ¶
func (c CommandsByName) Less(i, j int) bool
Less returns true if item at index i < item at index j
type Context ¶
type Context struct { // Args are the command line arguments Args []string // Signal from the system Signal os.Signal // Command that owns the context Command *Command // Parent Context Parent *Context // Writer writer to write output to Writer io.Writer // ErrWriter writes error output ErrWriter io.Writer // Metadata store Metadata map[string]interface{} }
Context represents the execution context
func (*Context) Duration ¶
Duration looks up the value of a local DurationFlag, returns 0 if not found
func (*Context) GlobalBool ¶
GlobalBool looks up the value of a global BoolFlag, returns false if not found
func (*Context) GlobalDuration ¶
GlobalDuration looks up the value of a global DurationFlag, returns 0 if not found
func (*Context) GlobalFloat32 ¶
GlobalFloat32 looks up the value of a global Float64Flag, returns 0 if not found
func (*Context) GlobalFloat64 ¶
GlobalFloat64 looks up the value of a global Float64Flag, returns 0 if not found
func (*Context) GlobalHardwareAddr ¶
func (ctx *Context) GlobalHardwareAddr(name string) net.HardwareAddr
GlobalHardwareAddr looks up the value of a global HardwareAddrFlag, returns nil if not found
func (*Context) GlobalInt ¶
GlobalInt looks up the value of a global IntFlag, returns 0 if not found
func (*Context) GlobalInt64 ¶
GlobalInt64 looks up the value of a global Int64Flag, returns 0 if not found
func (*Context) GlobalString ¶
GlobalString looks up the value of a global StringFlag, returns "" if not found
func (*Context) GlobalStringSlice ¶
GlobalStringSlice looks up the value of a global StringSliceFlag, returns nil if not found
func (*Context) GlobalTime ¶
GlobalTime looks up the value of a global TimeFlag, returns 0 if not found
func (*Context) GlobalUInt ¶
GlobalUInt looks up the value of a global UIntFlag, returns 0 if not found
func (*Context) GlobalUInt64 ¶
GlobalUInt64 looks up the value of a global UInt64Flag, returns 0 if not found
func (*Context) GlobalURL ¶
GlobalURL looks up the value of a global URLFlag, returns nil if not found
func (*Context) HardwareAddr ¶
func (ctx *Context) HardwareAddr(name string) net.HardwareAddr
HardwareAddr looks up the value of a local HardwareddrFlag, returns nil if not found
func (*Context) StringSlice ¶
StringSlice looks up the value of a local StringSliceFlag, returns nil if not found
type DurationFlag ¶
type DurationFlag struct { Name string Path string Usage string EnvVar string Value time.Duration Hidden bool Required bool Validator Validator }
DurationFlag is a flag with type time.Duration
func (*DurationFlag) Get ¶
func (f *DurationFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*DurationFlag) Set ¶
func (f *DurationFlag) Set(value string) (err error)
Set is called once, in command line order, for each flag present. The flag package may call the String method with a zero-valued receiver, such as a nil pointer.
func (*DurationFlag) String ¶
func (f *DurationFlag) String() string
String returns the value as string
func (*DurationFlag) Validate ¶
func (f *DurationFlag) Validate(ctx *Context) error
Validate validates the flag
type EnvProvider ¶
type EnvProvider struct{}
EnvProvider parses environment variables
func (*EnvProvider) Provide ¶
func (p *EnvProvider) Provide(ctx *Context) error
Provide parses the args
type ExitError ¶
type ExitError struct {
// contains filtered or unexported fields
}
ExitError fulfills both the builtin `error` interface and `ExitCoder`
func NewExitError ¶
NewExitError makes a new ExitError
func NotFoundCommandError ¶
NotFoundCommandError makes a new ExitError for missing command
func NotFoundFlagError ¶
NotFoundFlagError makes a new ExitError for missing flags
func (*ExitError) Code ¶
Code returns the exit code, fulfilling the interface required by `ExitCoder`
func (*ExitError) Error ¶
Error returns the string message, fulfilling the interface required by `error`
type ExitErrorCollector ¶
type ExitErrorCollector []error
ExitErrorCollector is an error that wraps multiple errors.
func (ExitErrorCollector) Code ¶
func (errs ExitErrorCollector) Code() int
Code returns the exit code, fulfilling the interface required by ExitCoder
func (ExitErrorCollector) Error ¶
func (errs ExitErrorCollector) Error() string
Error implements the error interface.
func (ExitErrorCollector) IsEmpty ¶
func (errs ExitErrorCollector) IsEmpty() bool
IsEmpty returns true if the collector is empty
func (ExitErrorCollector) Unwrap ¶
func (errs ExitErrorCollector) Unwrap() error
Unwrap unwraps the error
func (*ExitErrorCollector) Wrap ¶
func (errs *ExitErrorCollector) Wrap(err error)
Wrap wraps an error
type ExitErrorHandlerFunc ¶
OnExitErrorHandlerFunc is executed if provided in order to handle ExitError values returned by Actions and Before/After functions.
type Flag ¶
Flag is the interface to the dynamic value stored in a flag. (The default value is represented as a string.)
If a Value has an IsBoolFlag() bool method returning true, the command-line parser makes -name equivalent to -name=true rather than using the next command-line argument.
Set is called once, in command line order, for each flag present. The flag package may call the String method with a zero-valued receiver, such as a nil pointer.
Getter is an interface that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
type FlagAccessor ¶
FlagAccessor access the flag's field
func NewFlagAccessor ¶
func NewFlagAccessor(flag Flag) *FlagAccessor
NewFlagAccessor returns new flag accessor
func (*FlagAccessor) IsBoolFlag ¶
func (f *FlagAccessor) IsBoolFlag() bool
IsBoolFlag returns true if the flag is bool
func (*FlagAccessor) IsPathFlag ¶
func (f *FlagAccessor) IsPathFlag() bool
IsPathFlag returns true if the flag is path
func (*FlagAccessor) ReadFrom ¶
func (f *FlagAccessor) ReadFrom(r io.Reader) (int64, error)
ReadFrom reads data from r until EOF or error. The return value n is the number of bytes read. Any error except EOF encountered during the read is also returned.
func (*FlagAccessor) Set ¶
func (f *FlagAccessor) Set(value string) error
Set is called once, in command line order, for each flag present. The flag package may call the String method with a zero-valued receiver, such as a nil pointer.
func (*FlagAccessor) String ¶
func (f *FlagAccessor) String() string
String returns the flag as string
func (*FlagAccessor) Validate ¶
func (f *FlagAccessor) Validate(ctx *Context) error
Validate validates the flag
type FlagProvider ¶
type FlagProvider struct {
// contains filtered or unexported fields
}
FlagProvider parses the CLI flags
func (*FlagProvider) Provide ¶
func (p *FlagProvider) Provide(ctx *Context) error
Provide parses the args
type FlagsByName ¶
type FlagsByName []Flag
FlagsByName is a slice of Flag
func (FlagsByName) Less ¶
func (f FlagsByName) Less(i, j int) bool
Less returns true if item at index i < item at index j
type Float32Flag ¶
type Float32Flag struct { Name string Path string Usage string EnvVar string Value float32 Hidden bool Required bool Validator Validator }
Float32Flag is a flag with type float32
func (*Float32Flag) Get ¶
func (f *Float32Flag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*Float32Flag) Set ¶
func (f *Float32Flag) Set(value string) error
Set is called once, in command line order, for each flag present. The flag package may call the String method with a zero-valued receiver, such as a nil pointer.
func (*Float32Flag) String ¶
func (f *Float32Flag) String() string
String returns the value as string
func (*Float32Flag) Validate ¶
func (f *Float32Flag) Validate(ctx *Context) error
Validate validates the flag
type Float64Flag ¶
type Float64Flag struct { Name string Path string Usage string EnvVar string Value float64 Hidden bool Required bool Validator Validator }
Float64Flag is a flag with type float64
func (*Float64Flag) Get ¶
func (f *Float64Flag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*Float64Flag) Set ¶
func (f *Float64Flag) Set(value string) (err error)
Set is called once, in command line order, for each flag present. The flag package may call the String method with a zero-valued receiver, such as a nil pointer.
func (*Float64Flag) String ¶
func (f *Float64Flag) String() string
String returns the value as string
func (*Float64Flag) Validate ¶
func (f *Float64Flag) Validate(ctx *Context) error
Validate validates the flag
type HardwareAddrFlag ¶
type HardwareAddrFlag struct { Name string Path string Usage string EnvVar string Value net.HardwareAddr Hidden bool Required bool Validator Validator }
HardwareAddrFlag is a flag with type net.HardwareAddr
func (*HardwareAddrFlag) Get ¶
func (f *HardwareAddrFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*HardwareAddrFlag) Set ¶
func (f *HardwareAddrFlag) Set(value string) (err error)
Set is called once, in command line order, for each flag present. The flag package may call the String method with a zero-valued receiver, such as a nil pointer.
func (*HardwareAddrFlag) String ¶
func (f *HardwareAddrFlag) String() string
String returns the value as string
func (*HardwareAddrFlag) Validate ¶
func (f *HardwareAddrFlag) Validate(ctx *Context) error
Validate validates the flag
type IPFlag ¶
type IPFlag struct { Name string Path string Usage string EnvVar string Value net.IP Hidden bool Required bool Validator Validator }
IPFlag is a flag with type net.IP
func (*IPFlag) Get ¶
func (f *IPFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
type Int64Flag ¶
type Int64Flag struct { Name string Path string Usage string EnvVar string Value int64 Hidden bool Required bool Validator Validator }
Int64Flag is a flag with type int64
func (*Int64Flag) Get ¶
func (f *Int64Flag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
type IntFlag ¶
type IntFlag struct { Name string Path string Usage string EnvVar string Value int Hidden bool Required bool Validator Validator }
IntFlag is a flag with type int
func (*IntFlag) Get ¶
func (f *IntFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
type JSONFlag ¶
type JSONFlag struct { Name string Path string Usage string EnvVar string Value interface{} Hidden bool Required bool Validator Validator }
JSONFlag is a flag with type json document
func (*JSONFlag) Get ¶
func (f *JSONFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*JSONFlag) IsPathFlag ¶
IsPathFlag returns true if the flag is path
func (*JSONFlag) ReadFrom ¶
ReadFrom reads data from r until EOF or error. The return value n is the number of bytes read. Any error except EOF encountered during the read is also returned.
type PathProvider ¶
type PathProvider struct {
IsPathFlag bool
}
PathProvider parses flags from file
func (*PathProvider) Provide ¶
func (p *PathProvider) Provide(ctx *Context) error
Provide parses the args
type SignalFunc ¶
SignalFunc is an action to execute after a system signal
type StringFlag ¶
type StringFlag struct { Name string Path string Usage string EnvVar string Value string Hidden bool Required bool Validator Validator }
StringFlag is a flag with type string
func (*StringFlag) Get ¶
func (f *StringFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*StringFlag) Set ¶
func (f *StringFlag) Set(value string) error
Set is called once, in command line order, for each flag present. The flag package may call the String method with a zero-valued receiver, such as a nil pointer.
func (*StringFlag) Validate ¶
func (f *StringFlag) Validate(ctx *Context) error
Validate validates the flag
type StringSliceFlag ¶
type StringSliceFlag struct { Name string Path string Usage string EnvVar string Value []string Hidden bool Required bool Validator Validator }
StringSliceFlag is a flag with type *StringSlice
func (*StringSliceFlag) Get ¶
func (f *StringSliceFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*StringSliceFlag) Set ¶
func (f *StringSliceFlag) Set(value string) error
Set is called once, in command line order, for each flag present. The flag package may call the String method with a zero-valued receiver, such as a nil pointer.
func (*StringSliceFlag) String ¶
func (f *StringSliceFlag) String() string
String returns the value as string
func (*StringSliceFlag) Validate ¶
func (f *StringSliceFlag) Validate(ctx *Context) error
Validate validates the flag
type TimeFlag ¶
type TimeFlag struct { Name string Path string Usage string EnvVar string Format string Value time.Time Hidden bool Required bool Validator Validator }
TimeFlag is a flag with type time.Time
func (*TimeFlag) Get ¶
func (f *TimeFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
type UInt64Flag ¶
type UInt64Flag struct { Name string Path string Usage string EnvVar string Value uint64 Hidden bool Required bool Validator Validator }
UInt64Flag is a flag with type uint
func (*UInt64Flag) Get ¶
func (f *UInt64Flag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*UInt64Flag) Set ¶
func (f *UInt64Flag) Set(value string) (err error)
Set is called once, in command line order, for each flag present. The flag package may call the String method with a zero-valued receiver, such as a nil pointer.
func (*UInt64Flag) Validate ¶
func (f *UInt64Flag) Validate(ctx *Context) error
Validate validates the flag
type UIntFlag ¶
type UIntFlag struct { Name string Path string Usage string EnvVar string Value uint Hidden bool Required bool Validator Validator }
UIntFlag is a flag with type uint64
func (*UIntFlag) Get ¶
func (f *UIntFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
type URLFlag ¶
type URLFlag struct { Name string Path string Usage string EnvVar string Value *url.URL Hidden bool Required bool Validator Validator }
URLFlag is a flag with type url.URL
func (*URLFlag) Get ¶
func (f *URLFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
type UsageErrorFunc ¶
OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying customized usage error messages. This function is able to replace the original error messages. If this function is not set, the "Incorrect usage" is displayed and the execution is interrupted.
type Validator ¶
type Validator interface { // Validate validates the value Validate(ctx *Context, value interface{}) error }
Validator converts values
type ValidatorFunc ¶
ValidatorFunc validates a flag
func (ValidatorFunc) Validate ¶
func (fn ValidatorFunc) Validate(ctx *Context, value interface{}) error
Validate validates the value
type XMLFlag ¶
type XMLFlag struct { Name string Path string Usage string EnvVar string Value interface{} Hidden bool Required bool Validator Validator }
XMLFlag is a flag with type XMLDocument
func (*XMLFlag) Get ¶
func (f *XMLFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*XMLFlag) IsPathFlag ¶
IsPathFlag returns true if the flag is path
func (*XMLFlag) ReadFrom ¶
ReadFrom reads data from r until EOF or error. The return value n is the number of bytes read. Any error except EOF encountered during the read is also returned.
type YAMLFlag ¶
type YAMLFlag struct { Name string Path string Usage string EnvVar string Value interface{} Hidden bool Required bool Validator Validator }
YAMLFlag is a flag with type yaml document
func (*YAMLFlag) Get ¶
func (f *YAMLFlag) Get() interface{}
Get is a function that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
func (*YAMLFlag) IsPathFlag ¶
IsPathFlag returns true if the flag is path
func (*YAMLFlag) ReadFrom ¶
ReadFrom reads data from r until EOF or error. The return value n is the number of bytes read. Any error except EOF encountered during the read is also returned.