Documentation
¶
Index ¶
- Variables
- func DefaultComplete(c *Command) (err error)
- func DefaultParseEnv(c *Command, env []string) (rest []string, err error)
- func DefaultParseFlag(c *Command, arg string, args []string) (nextArgs []string, err error)
- func FullName(c *Command) (r []string)
- func GetEnvPrefix(c *Command) string
- func MainName(n string) string
- func ParseEnv(c *Command, env []string) ([]string, error)
- func ParseFlag(c *Command, arg string, more []string) ([]string, error)
- func Run(c *Command, args, env []string) (err error)
- func RunAndExit(c *Command, args, env []string)
- type Action
- type Args
- type Command
- func (c *Command) Bool(n string) bool
- func (c *Command) Command(n string) *Command
- func (c *Command) Duration(n string) time.Duration
- func (c *Command) Flag(n string) *Flag
- func (c *Command) Float32(n string) float32
- func (c *Command) Float64(n string) float64
- func (c *Command) Getenv(key string) (val string)
- func (c *Command) Int(n string) int
- func (c *Command) Int64(n string) int64
- func (c *Command) LookupEnv(key string) (string, bool)
- func (c *Command) MainName() string
- func (c *Command) String(n string) string
- func (c *Command) Uint(n string) uint
- func (c *Command) Uint64(n string) uint64
- type Flag
- type FlagAction
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoSuchCommand = stderrors.New("no such command") ErrNoArgsExpected = stderrors.New("no args expected") )
View Source
var ( ErrExit = stderrors.New("exit") // to stop command execution from flag or before handler ErrNoSuchFlag = stderrors.New("no such flag") )
View Source
var CompleteCmd = &Command{ Name: "_complete", Usage: "[bash|zsh]", Description: "print shell completion script", Action: completeAuto, Hidden: true, Commands: []*Command{{ Name: "bash", Action: completeBash, }, { Name: "zsh", Action: completeZsh, }}, }
View Source
var DefaultFlags = []*Flag{ FlagfileFlag, EnvfileFlag, HelpFlag, }
View Source
var EnvCmd = &Command{
Name: "env",
Action: envAction,
}
View Source
var EnvfileFlag = &Flag{
Name: "envfile",
Description: "load env variables from file",
Action: envfile,
}
View Source
var ErrCouldNotDetermineShell = errors.New("couldn't determine the shell")
View Source
var FlagfileFlag = &Flag{
Name: "flagfile,ff",
Description: "load flags from file",
Action: flagfile,
}
FlagfileFlag replaces this flag occurrence with the given file content split on spaces. # comments are also supported.
View Source
var HelpFlag = &Flag{
Name: "help,h",
Usage: "=[hidden]",
Description: "print command help end exit",
Action: defaultHelp,
}
Functions ¶
func DefaultComplete ¶
func DefaultParseFlag ¶
func GetEnvPrefix ¶
func RunAndExit ¶
Types ¶
type Command ¶
type Command struct { Parent *Command OSArgs []string OSEnv []string Arg0 string // command name Args Args // must be initialized to cli.Args{} if arguments expected Env []string // env vars not used for local flags Chosen *Command // chosen command Name string // comma separated list of aliases Group string Usage string // [flags] {args...} Description string // short textual description of the command Help string // full description Before Action After Action Action Action Flags []*Flag Commands []*Command // Hide from help. Hidden bool // EnvPrefix used to capture flag values from env vars. // No capturing is done if empty. // Args have precedence over env vars. // Env vars have precedence over default values. // Inherited by subcommands. EnvPrefix string // ParseEnv and ParseFlag override default behaviour. // Both are inherited by subcommands. ParseEnv func(c *Command, env []string) ([]string, error) ParseFlag func(c *Command, arg string, args []string) ([]string, error) Stdout io.Writer // set to os.Stdout if nil Stderr io.Writer // the same as Stdout }
type FlagAction ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.