executor

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const AttemptsLimit = 3

AttemptsLimit is the limit value for the number of attempts to obtain user data in terminal mode.

View Source
const CommandQuit = ":q"

CommandQuit is the command for exit from Interactive mode.

View Source
const CommandsResponseSeparator = "--------"

CommandsResponseSeparator is symbols that is written between responses of several commands if more than one command was called. TODO: Add to config.

Variables

View Source
var (
	// ErrEmptyAddress is returned when executed command without setting address
	// in single mode.
	ErrEmptyAddress = errors.New("address is not set: to set address add -a host:port")

	// ErrEmptyAddress is returned when executed command without setting password
	// in single mode.
	ErrEmptyPassword = errors.New("password is not set: to set password add -p password")

	// ErrToManyFails is returned in terminal mode when exceeding the limit of
	// user data retrieval attempts.
	ErrToManyFails = errors.New("to many fails")

	// ErrCommandEmpty is returned when executed command length equal 0.
	ErrCommandEmpty = errors.New("command is not set")
)

Errors.

Functions

func CheckCredentials

func CheckCredentials(ses *config.Session) error

CheckCredentials sends auth request for remote server. Returns en error if address or password is incorrect.

func Execute

func Execute(w io.Writer, ses *config.Session, commands ...string) error

Execute sends command to Execute to the remote server and prints the response.

func Interactive

func Interactive(r io.Reader, w io.Writer, ses *config.Session) error

Interactive reads stdin, parses commands, executes them on remote server and prints the responses.

Types

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor is a cli commands execute wrapper.

func NewExecutor

func NewExecutor(r io.Reader, w io.Writer, version string) *Executor

NewExecutor creates a new Executor.

func (*Executor) NewSession

func (executor *Executor) NewSession(c *cli.Context) (*config.Session, error)

NewSession parses os args and config file for connection details to a remote server. If the address and password flags were received the configuration file is ignored.

func (*Executor) Run

func (executor *Executor) Run(arguments []string) error

Run is the entry point to the cli app.

Jump to

Keyboard shortcuts

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