Documentation ¶
Index ¶
- func Handle(command Commander)
- type Command
- type Commander
- type Context
- func (ctx *Context) CheckArgNum(expected int) error
- func (ctx *Context) CheckFlagsSet(flagNames []string) error
- func (ctx *Context) CheckKVFlag(flagName string) (map[string]string, error)
- func (ctx *Context) CheckStructFlag(flagValues []string) ([]map[string]interface{}, error)
- func (ctx *Context) IDOrName(idFromNameFunc func(*gophercloud.ServiceClient, string) (string, error)) (string, error)
- type PipeHandler
- type PreCSVer
- type PreJSONer
- type PreTabler
- type Resource
- type StreamPipeHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
type Command struct { // See `Context` Ctx *Context }
Command is the type that commands have.
type Commander ¶
type Commander interface { // See `Context`. Context() *Context // Keys returns the keys available for the command output. Keys() []string // ServiceClientType returns the type of the service client to use. ServiceClientType() string // HandleFlags processes flags for the command that are relevant for both piped // and non-piped commands. HandleFlags(*Resource) error // Execute executes the command's HTTP request. Execute(*Resource) }
Commander is an interface that all commands implement.
type Context ¶
type Context struct { // CLIContext is the context that the `cli` library uses. `rack` uses it to // access flags. CLIContext *cli.Context // ServiceClient is the Rackspace service client used to authenticate the user // and carry out the requests while processing the command. ServiceClient *gophercloud.ServiceClient // ServiceClientType is the type of Rackspace service client used (e.g. compute). ServiceClientType string // Results is a channel into which commands send results. It allows for streaming // output. Results chan *Resource GlobalOptions struct { // contains filtered or unexported fields } // contains filtered or unexported fields }
Context is a global context that `rack` uses.
func (*Context) CheckArgNum ¶
CheckArgNum checks that the provided number of arguments has the same cardinality as the expected number of arguments.
func (*Context) CheckFlagsSet ¶
CheckFlagsSet checks that the given flag names are set for the command.
func (*Context) CheckKVFlag ¶
CheckKVFlag is a function used for verifying the format of a key-value flag.
func (*Context) CheckStructFlag ¶
CheckStructFlag is a function used for verifying the format of a struct flag.
func (*Context) IDOrName ¶
func (ctx *Context) IDOrName(idFromNameFunc func(*gophercloud.ServiceClient, string) (string, error)) (string, error)
IDOrName is a function for retrieving a resources unique identifier based on whether he or she passed an `id` or a `name` flag.
type PipeHandler ¶
type PipeHandler interface { // Commander is an interface that all commands will implement. Commander // HandleSingle contains logic for processing a single resource. This method // will be used if input isn't sent to STDIN, so it will contain, for example, // logic for handling flags that would be mandatory if otherwise not piped in. HandleSingle(*Resource) error // HandlePipe is a method that commands implement for processing piped input. HandlePipe(*Resource, string) error // StdinField is the field that the command accepts on STDIN. StdinField() string }
PipeHandler is an interface that commands implement if they can accept input from STDIN.
type PreJSONer ¶
PreJSONer is an interface that commands will satisfy if they have a `PreJSON` method.
type PreTabler ¶
PreTabler is an interface that commands will satisfy if they have a `PreTable` method.
type Resource ¶
type Resource struct { // Keys are the fields available to output. These may be limited by the `fields` // flag. Keys []string // Params will be the command-specific parameters, such as an instance ID or // list options. Params interface{} // Result will store the result of a single command. Result interface{} // Err will store any error encountered while processing the command. Err error }
Resource is a general resource from Rackspace. This object stores information about a single request and response from Rackspace.
func (*Resource) FlattenMap ¶
FlattenMap is used to flatten out a `map[string]map[string]*`
type StreamPipeHandler ¶
type StreamPipeHandler interface { // PipeHandler is an interface that commands implement if they can accept input // from STDIN. PipeHandler // StreamField is the field that the command accepts for streaming input on STDIN. StreamField() string // HandleStreamPipe is a method that commands implement for processing streaming, piped input. HandleStreamPipe(*Resource) error }
StreamPipeHandler is an interface that commands implement if they can stream input from STDIN.