executor

package
v0.0.0-...-afd5f29 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

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.

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

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

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

Errors.

Functions

This section is empty.

Types

type ExecuteCloser

type ExecuteCloser interface {
	Execute(command string) (string, error)
	Close() error
}

ExecuteCloser is the interface that groups Execute and Close methods.

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

func (executor *Executor) Close() error

Close closes connection to remote server.

func (*Executor) Dial

func (executor *Executor) Dial(ses *config.Session) error

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

func (*Executor) Execute

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

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

func (*Executor) Interactive

func (executor *Executor) 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.

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