Documentation
¶
Overview ¶
Package cli provides a zero-dependency subcommand framework shared across all MIST stack tools.
Each command gets its own flag set. Define flags on the command, then access parsed values in the Run handler:
cmd := &cli.Command{
Name: "serve",
Usage: "Start the server",
}
cmd.AddStringFlag("addr", ":8080", "Listen address")
cmd.AddIntFlag("workers", 4, "Number of workers")
cmd.Run = func(cmd *cli.Command, args []string) error {
addr := cmd.GetString("addr")
workers := cmd.GetInt("workers")
// ...
}
app.AddCommand(cmd)
Index ¶
- type App
- type Command
- func (c *Command) AddBoolFlag(name string, value bool, usage string)
- func (c *Command) AddFloat64Flag(name string, value float64, usage string)
- func (c *Command) AddInt64Flag(name string, value int64, usage string)
- func (c *Command) AddIntFlag(name string, value int, usage string)
- func (c *Command) AddStringFlag(name, value, usage string)
- func (c *Command) GetBool(name string) bool
- func (c *Command) GetFloat64(name string) float64
- func (c *Command) GetInt(name string) int
- func (c *Command) GetInt64(name string) int64
- func (c *Command) GetString(name string) string
- func (c *Command) HasFlag(name string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
App is the top-level CLI application.
type Command ¶
type Command struct {
Name string
Usage string
Flags *flag.FlagSet
Run func(cmd *Command, args []string) error
// contains filtered or unexported fields
}
Command is a single CLI subcommand with its own flag set.
func (*Command) AddBoolFlag ¶
AddBoolFlag defines a boolean flag on this command.
func (*Command) AddFloat64Flag ¶
AddFloat64Flag defines a float64 flag on this command.
func (*Command) AddInt64Flag ¶
AddInt64Flag defines an int64 flag on this command.
func (*Command) AddIntFlag ¶
AddIntFlag defines an integer flag on this command.
func (*Command) AddStringFlag ¶
AddStringFlag defines a string flag on this command.
func (*Command) GetFloat64 ¶
GetFloat64 returns the parsed float64 flag value.
Click to show internal directories.
Click to hide internal directories.