Documentation ¶
Overview ¶
Package client describes all client-side operations.
Index ¶
- func Dispatch(conf *config.Opts, args []string) bool
- func RegisterOperation(name string, operation Operation)
- type Client
- func (c *Client) Close() error
- func (c *Client) CommandExists(cmd string) bool
- func (c *Client) Connected() bool
- func (c *Client) EnsureServerIsRunning()
- func (c *Client) Error() error
- func (c *Client) EstablishConnection()
- func (c *Client) Failed() bool
- func (c *Client) PrintAllOperationsHelp()
- func (c *Client) PrintError(err error)
- func (c *Client) PrintMessage(message string)
- func (c *Client) PrintResponse(resp msg.Response)
- func (c *Client) PrintShortDescription(desc argparse.Description)
- func (c *Client) PrintSingleOperationHelp(cmd string) error
- func (cl *Client) Read(p []byte) (n int, err error)
- func (c *Client) ReceiveFromServer() msg.Response
- func (c *Client) RunServer()
- func (c *Client) SendReceivePrint(cmd msg.Cmd)
- func (c *Client) SendToServer(cmd msg.Cmd)
- func (c *Client) ServerIsRunning() bool
- type Operation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dispatch ¶
Dispatch to the appropriate command handler based on the given arguments. Returns true if all operations succeeded, false otherwise.
func RegisterOperation ¶
RegisterOperation makes a client-side operation available. This function is called indirectly from other packages' init() functions.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a type bundling everything required for client-side operation.
func (*Client) CommandExists ¶
Whether a command with the given name exists.
func (*Client) EnsureServerIsRunning ¶
func (c *Client) EnsureServerIsRunning()
EnsureServerIsRunning will do nothing if the server is up, else it will start it.
func (*Client) EstablishConnection ¶
func (c *Client) EstablishConnection()
EstablishConnection ensures the server is up and the client is connected.
func (*Client) PrintAllOperationsHelp ¶
func (c *Client) PrintAllOperationsHelp()
PrintAllOperationsHelp prints a command usage overview for the user.
func (*Client) PrintError ¶
PrintError prints an error message for the user.
func (*Client) PrintMessage ¶
PrintMessage prints the given message for the user.
func (*Client) PrintResponse ¶
PrintResponse print a server response for the user to read.
func (*Client) PrintShortDescription ¶
func (c *Client) PrintShortDescription(desc argparse.Description)
Print a short command description to the user.
func (*Client) PrintSingleOperationHelp ¶
PrintSingleOperationHelp prints the detailed help for a single command.
func (*Client) ReceiveFromServer ¶
ReceiveFromServer receives a response from the server.
func (*Client) RunServer ¶
func (c *Client) RunServer()
RunServer will yield the current process to a freshly started server.
func (*Client) SendReceivePrint ¶
SendReceivePrint executes a typical client lifecycle: a server round-trip. This will establish a connection, send the command, receive a response, and print it.
func (*Client) SendToServer ¶
SendToServer sends the given command to the server.
func (*Client) ServerIsRunning ¶
ServerIsRunning tries to determine whether the server is running.
type Operation ¶
type Operation interface { // Execute client-side behaviour based on args. ClientExec(cl *Client, cmd msg.Cmd) error // Command line argument parser for this operation. Parser() *argparse.Parser // Describe usage for this operation. DescribeShort() argparse.Description HelpHeaderAndFooter() (string, string) }
Operation is the common interface for all client-side operations.