Documentation
¶
Index ¶
- Variables
- type App
- type BuildInfo
- type Command
- type Context
- func (c *Context) Arg(n int) string
- func (c *Context) Args() []string
- func (c *Context) GetBool(name string) bool
- func (c *Context) GetFloat32(name string) float32
- func (c *Context) GetFloat64(name string) float64
- func (c *Context) GetInt(name string) int
- func (c *Context) GetInt16(name string) int16
- func (c *Context) GetInt32(name string) int32
- func (c *Context) GetInt64(name string) int64
- func (c *Context) GetInt8(name string) int8
- func (c *Context) GetString(name string) string
- func (c *Context) GetStringSlice(name string) []string
- func (c *Context) GetUint(name string) uint
- func (c *Context) GetUint16(name string) uint16
- func (c *Context) GetUint32(name string) uint32
- func (c *Context) GetUint64(name string) uint64
- func (c *Context) GetUint8(name string) uint8
- func (c *Context) Global() *Context
- func (c *Context) IsSet(name string) bool
- func (c *Context) NArg() int
- func (c *Context) Name() string
- func (c *Context) Parent() *Context
- func (c *Context) ShowError(err error)
- func (c *Context) ShowHelp()
- func (c *Context) ShowHelpAndExit(code int)
- type Flag
- type HelpContext
- func (c *HelpContext) AuthorLines() []string
- func (c *HelpContext) ExampleLines() []string
- func (c *HelpContext) Level() int
- func (c *HelpContext) SeeAlsoLines() []string
- func (c *HelpContext) UsageTextLines() []string
- func (c *HelpContext) VisibleCommands() []*Command
- func (c *HelpContext) VisibleCommandsUsageLines() []string
- func (c *HelpContext) VisibleFlags() []*Flag
- func (c *HelpContext) VisibleFlagsUsageLines() []string
- type Value
Constants ¶
This section is empty.
Variables ¶
var HelpTemplate = `` /* 800-byte string literal not displayed */
HelpTemplate is the text template for the Default help topic. go-cli uses text/template to render templates. You can render custom help text by setting this variable.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { // The name of the program. Defaults to path.Base(os.Args[0]) Name string // The version of the program Version string // Short description of the program. Usage string // Text to override the USAGE section of help UsageText string // Long description of the program Description string // Authors of the program Authors string // Examples of the program Examples string // SeeAlso of the program SeeAlso string // build information, show in --version BuildInfo *BuildInfo // List of flags to parse Flags []*Flag // List of commands to execute Commands []*Command // Hidden --help and --version from usage HiddenHelp bool HiddenVersion bool // Display full help ShowHelp func(*HelpContext) // Display full version ShowVersion func(*App) // The action to execute when no subcommands are specified Action func(*Context) // Execute this function if the proper command cannot be found OnCommandNotFound func(*Context, string) // Handler if panic in app.Action() and command.Action() OnActionPanic func(*Context, error) }
App is the main structure of a cli application
type BuildInfo ¶
BuildInfo stores app build info
func ParseBuildInfo ¶
ParseBuildInfo parse a buildinfo string info struct
type Command ¶
type Command struct { // The name of the program. Defaults to path.Base(os.Args[0]) Name string // Short description of the program. Usage string // Text to override the USAGE section of help UsageText string // Long description of the program Description string // Examples of the program Examples string // SeeAlso of the program SeeAlso string // List of flags to parse Flags []*Flag // List of commands to execute Commands []*Command // hidden --help from usage HiddenHelp bool // Treat all flags as normal arguments if true SkipFlagParsing bool // Boolean to hide this command from help Hidden bool // Display full help ShowHelp func(*HelpContext) // The action to execute when no subcommands are specified Action func(*Context) // Execute this function if the proper command cannot be found OnCommandNotFound func(*Context, string) }
Command is a subcommand for a cli.App
type Context ¶
type Context struct {
// 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 (*Context) GetFloat32 ¶
GetFloat32 returns flag value as float32
func (*Context) GetFloat64 ¶
GetFloat64 returns flag value as float64
func (*Context) GetStringSlice ¶
GetStringSlice returns flag value as string slice
func (*Context) ShowHelpAndExit ¶ added in v1.4.6
ShowHelpAndExit shows help and exit
type Flag ¶
type Flag struct { Name string // name as it appears on command line Usage string // help message Placeholder string // placeholder in usage Hidden bool // allow flags to be hidden from help/usage text IsBool bool // if the flag is bool value DefValue string // default value (as text); for usage message NoOptDefValue string // default value (as text); if the flag is on the command line without any options EnvVar string // default value load from environ Value interface{} // returns final value // contains filtered or unexported fields }
Flag represents the state of a flag
type HelpContext ¶
type HelpContext struct { Name string Version string Usage string UsageText string Description string Authors string Examples string SeeAlso string Flags []*Flag Commands []*Command }
HelpContext is a struct for output help
func (*HelpContext) AuthorLines ¶
func (c *HelpContext) AuthorLines() []string
AuthorLines splits line for authors
func (*HelpContext) ExampleLines ¶
func (c *HelpContext) ExampleLines() []string
ExampleLines splits line for examples
func (*HelpContext) Level ¶
func (c *HelpContext) Level() int
Level return command/subcommand's level
func (*HelpContext) SeeAlsoLines ¶
func (c *HelpContext) SeeAlsoLines() []string
SeeAlsoLines splits line for see also
func (*HelpContext) UsageTextLines ¶
func (c *HelpContext) UsageTextLines() []string
UsageTextLines splits line for usage
func (*HelpContext) VisibleCommands ¶
func (c *HelpContext) VisibleCommands() []*Command
VisibleCommands returns commands which are visible
func (*HelpContext) VisibleCommandsUsageLines ¶
func (c *HelpContext) VisibleCommandsUsageLines() []string
VisibleCommandsUsageLines splits line for commands
func (*HelpContext) VisibleFlags ¶
func (c *HelpContext) VisibleFlags() []*Flag
VisibleFlags returns flags which are visible
func (*HelpContext) VisibleFlagsUsageLines ¶
func (c *HelpContext) VisibleFlagsUsageLines() []string
VisibleFlagsUsageLines splits line for flags
Source Files
¶
- app.go
- build_info.go
- command.go
- command_line_parser.go
- context.go
- flag.go
- flag_bool.go
- flag_float32.go
- flag_float64.go
- flag_float64_slice.go
- flag_int.go
- flag_int16.go
- flag_int32.go
- flag_int64.go
- flag_int8.go
- flag_int_slice.go
- flag_ip.go
- flag_ip_mask.go
- flag_ip_net.go
- flag_ip_net_slice.go
- flag_ip_slice.go
- flag_string.go
- flag_string_slice.go
- flag_time.go
- flag_time_duration.go
- flag_time_location.go
- flag_uint.go
- flag_uint16.go
- flag_uint32.go
- flag_uint64.go
- flag_uint8.go
- flag_uint_slice.go
- flag_url.go
- flag_url_slice.go
- help.go