Documentation
¶
Index ¶
- type BodyTransformError
- type CliHandler
- type EmptyCommandLineError
- type Handler
- type Header
- type Headers
- func (h *Headers) Append(k, v string)
- func (h *Headers) Contains(k string) bool
- func (h *Headers) Delete(k string)
- func (h *Headers) DeleteAll(k string)
- func (h *Headers) Get(k string) string
- func (h *Headers) GetAll(k string) []string
- func (h *Headers) Keys() []string
- func (h *Headers) Set(k, v string)
- type Message
- type MultiLineCommandLineError
- type Request
- type Response
- type UnknownCommandError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyTransformError ¶
type BodyTransformError interface {
error
}
type CliHandler ¶
type CliHandler interface {
Register(handler Handler)
Execute(ctx context.Context, cmdline string) (Message, error)
DescendHandlers(ctx context.Context, resp *Response, req *Request)
}
func NewCliHandler ¶
func NewCliHandler() CliHandler
NewCliHandler returns a new and empty CliHandler.
type EmptyCommandLineError ¶
type EmptyCommandLineError interface {
error
}
type Handler ¶
type Handler struct {
// Use is the one-line usage message.
// Example: add [-F flag-val | -D flag-val] argument-val
Use string
// Short
Short string
// Command is the fully qualified command string. If this is a sub-command
// then the fully qualified string is "parent:sub:command"
Command string
// HandlerFn is the function to invoke to handle the command. When
// HandlerFn is invoked the command string will be striped from 'args'
HandlerFn func(ctx context.Context, resp *Response, req *Request)
}
type Header ¶
Header is a single key/value header field where both the key and the value are strings in the spirit of RFC5322, although necessarily conformant.
type Headers ¶
type Headers []Header
Headers is aliased so that methods can be implemented
func (*Headers) Get ¶
Get returns the value of the first header with key 'k' or the zero value string, ("")
type Message ¶
Message is the returned result of passing a command string into the CliHandler's Execute() function.
type MultiLineCommandLineError ¶
type MultiLineCommandLineError interface {
error
}
type Request ¶
type Request struct {
Command string
Args []string
CmdHandler CliHandler
}
Request is the internal structure used to pass a command request down the handler stack. Each level in the stack may mutate the Request object.
type Response ¶
Response is the internal structure used to return results from a command. A Response may be modified by each nested command as it is returned up the stack.
type UnknownCommandError ¶
type UnknownCommandError interface {
error
}