Documentation ¶
Index ¶
- Constants
- func Fatal(err error)
- type App
- type CallbackHandler
- type Command
- type CommandHandler
- type Context
- func (c *Context) Argument(name string) string
- func (c *Context) Confirm(msg string) bool
- func (c *Context) Flag(name string) (interface{}, error)
- func (c *Context) FlagCollection(name string) []string
- func (c *Context) FlagString(name string) string
- func (c *Context) Get(key string) interface{}
- func (c *Context) Input(msg string) (string, error)
- func (c *Context) Output(value string)
- func (c *Context) OutputJSON(obj interface{}) error
- func (c *Context) Outputf(format string, args ...interface{})
- func (c *Context) Set(key string, value interface{})
- type Error
- type FlagCollection
Constants ¶
const (
// Version is the current version of reaper
Version = "0.2.0"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
App contains the configuration for a command line application
func (*App) Before ¶
func (a *App) Before(fn CallbackHandler)
Before adds a function handler
This auto-excludes the help & version commands
func (*App) BeforeExcluding ¶
func (a *App) BeforeExcluding(fn CallbackHandler, exclude ...string)
BeforeExcluding adds a function handler but doesn't run it for the passed command names
func (*App) Command ¶
func (a *App) Command(name string, handler CommandHandler) *Command
Command creates a new command with the handler and adds it to the app.
type CallbackHandler ¶
CallbackHandler is the function signature for app callbacks
type Command ¶
Command represents a single sub-command in the application
func (*Command) Configure ¶
Configure calls the passed function with the command.
This is a convenience method for chaining `app.Command("thing", thingHandler).Configure(func(c *Command) { ... })`
func (*Command) IsInternal ¶
IsInternal returns if the command is defined from reaper
type CommandHandler ¶
CommandHandler is the function that will be called when a user performs a sub-command
type Context ¶
type Context struct { CommandName string // contains filtered or unexported fields }
Context is used to hold the state of the application
func (*Context) Flag ¶
Flag returns a flag with the passed name. If the flag is not found an error will be returned.
func (*Context) FlagCollection ¶
func (*Context) FlagString ¶
FlagString returns a flag string value.
This will panic if the flag does not exist
func (*Context) OutputJSON ¶
OutputJSON dumps the object into a pretty-printed JSON string.
type Error ¶
Error is a reaper error that can be returned from a command handler to exit with a specific status code
type FlagCollection ¶
type FlagCollection struct {
Values []string
}
FlagCollection contains a list of flags
func (*FlagCollection) String ¶
func (f *FlagCollection) String() string