client

package
v0.0.0-...-8cfe5f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package client describes all client-side operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(conf *config.Opts, args []string) bool

Dispatch to the appropriate command handler based on the given arguments. Returns true if all operations succeeded, false otherwise.

func RegisterOperation

func RegisterOperation(name string, operation Operation)

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) Close

func (c *Client) Close() error

Close the client's underlying connection.

func (*Client) CommandExists

func (c *Client) CommandExists(cmd string) bool

Whether a command with the given name exists.

func (*Client) Connected

func (c *Client) Connected() bool

Connected returns whether the client has is connected to the server.

func (*Client) EnsureServerIsRunning

func (c *Client) EnsureServerIsRunning()

EnsureServerIsRunning will do nothing if the server is up, else it will start it.

func (*Client) Error

func (c *Client) Error() error

Error returns the first error the client may have encountered, or nil.

func (*Client) EstablishConnection

func (c *Client) EstablishConnection()

EstablishConnection ensures the server is up and the client is connected.

func (*Client) Failed

func (c *Client) Failed() bool

Failed returns whether the client has encountered an error.

func (*Client) PrintAllOperationsHelp

func (c *Client) PrintAllOperationsHelp()

PrintAllOperationsHelp prints a command usage overview for the user.

func (*Client) PrintError

func (c *Client) PrintError(err error)

PrintError prints an error message for the user.

func (*Client) PrintMessage

func (c *Client) PrintMessage(message string)

PrintMessage prints the given message for the user.

func (*Client) PrintResponse

func (c *Client) PrintResponse(resp msg.Response)

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

func (c *Client) PrintSingleOperationHelp(cmd string) error

PrintSingleOperationHelp prints the detailed help for a single command.

func (*Client) Read

func (cl *Client) Read(p []byte) (n int, err error)

Read from the client's connection.

func (*Client) ReceiveFromServer

func (c *Client) ReceiveFromServer() msg.Response

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

func (c *Client) SendReceivePrint(cmd msg.Cmd)

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

func (c *Client) SendToServer(cmd msg.Cmd)

SendToServer sends the given command to the server.

func (*Client) ServerIsRunning

func (c *Client) ServerIsRunning() bool

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
	// Header and footer for this operation's help message
	HelpHeaderAndFooter() (string, string)
}

Operation is the common interface for all client-side operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL