Documentation
¶
Index ¶
- Variables
- func Edit(input []byte) (output []byte, err error)
- func Query(reader io.Reader, writer io.Writer, message string, acceptable ...string) (resp string)
- type Arguments
- func (args *Arguments) Args() []string
- func (args *Arguments) Bool(desc string) *bool
- func (args *Arguments) BoolVar(p *bool, desc string)
- func (args *Arguments) Duration(desc string) *time.Duration
- func (args *Arguments) DurationVar(p *time.Duration, desc string)
- func (args *Arguments) Float64(desc string) *float64
- func (args *Arguments) Float64Var(p *float64, desc string)
- func (args *Arguments) Int(desc string) *int
- func (args *Arguments) Int64(desc string) *int64
- func (args *Arguments) Int64Var(p *int64, desc string)
- func (args *Arguments) IntVar(p *int, desc string)
- func (args *Arguments) Len() int
- func (args *Arguments) Parse(input []string) error
- func (args *Arguments) String(desc string) *string
- func (args *Arguments) StringVar(p *string, desc string)
- func (args *Arguments) Uint(desc string) *uint
- func (args *Arguments) Uint64(desc string) *uint64
- func (args *Arguments) Uint64Var(p *uint64, desc string)
- func (args *Arguments) UintVar(p *uint, desc string)
- func (args *Arguments) Usage(writer io.Writer)
- func (args *Arguments) Var(value Value, desc string)
- func (args *Arguments) VarSlice(value SliceValue, desc string)
- type Command
- type CommandFunc
- type ErrorHandling
- type Option
- type SliceValue
- type Value
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnknownCommand = errors.New("Unknown command") ErrRequiredCommand = errors.New("A command is required") ErrNoCommandFunc = errors.New("No callback function was provided") )
View Source
var ErrNoEditor = errors.New("No editor found in environment")
Functions ¶
Types ¶
type Arguments ¶
type Arguments struct {
// contains filtered or unexported fields
}
func (*Arguments) Float64Var ¶
func (*Arguments) VarSlice ¶
func (args *Arguments) VarSlice(value SliceValue, desc string)
type Command ¶
type Command struct { Name string Description string Usage string Callback CommandFunc SubCommands []*Command Flags flag.FlagSet // contains filtered or unexported fields }
Command represents a single cli command. The idea is that a cli app is run such as:
program cmd <flags>
and can have nested commands:
program cmd1 <flags> subcmd1 <flags> ...
a Command object represents a single command in the hierarchy and is a placeholder to register subcommands
func New ¶
New will return a Command object that is initialized according to the supplied command options
type CommandFunc ¶
CommandFunc is the callback function that will be executed when a command is called. If the CommandFunc returns a non-nil error then processing stops immediately
func Callback ¶
func Callback(f interface{}, descriptions ...string) CommandFunc
type ErrorHandling ¶
type ErrorHandling int
const ( ExitOnError ErrorHandling = iota // Print usage and Call os.Exit(2). ContinueOnError // Return a descriptive error. PanicOnError // Call panic with a descriptive error. )
type Option ¶
type Option func(*Command)
func CallbackOption ¶
func CallbackOption(callback CommandFunc) Option
func DescOption ¶
func ErrorHandlingOption ¶
func ErrorHandlingOption(errorHandling ErrorHandling) Option
func OutputOption ¶
func UsageOption ¶
type SliceValue ¶
Click to show internal directories.
Click to hide internal directories.