genericcli

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const AnyNLPattern = `(\r\n|\n)`
View Source
const DefaultCLIConnectTimeout = 15 * time.Second

Variables

View Source
var ErrorCLILogin = errors.New("CLI login is not supported")

Functions

func GenericExecute

func GenericExecute(command cmd.Cmd, connector streamer.Connector, cli GenericCLI) (cmd.CmdRes, error)

Types

type GenericCLI

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

func MakeGenericCLI

func MakeGenericCLI(prompt, error expr.Expr, opts ...GenericCLIOption) GenericCLI

type GenericCLIOption

type GenericCLIOption func(*GenericCLI)

func WithAnswers

func WithAnswers(answers []cmd.Answer) GenericCLIOption

func WithAutoCommands

func WithAutoCommands(commands []cmd.Cmd) GenericCLIOption

WithAutoCommands add commands to run at the start

func WithEchoExprFn

func WithEchoExprFn(fn func(cmd.Cmd) expr.Expr) GenericCLIOption

WithEchoExprFn set echo expr fabric

func WithLoginExprs

func WithLoginExprs(login, password, passwordError expr.Expr) GenericCLIOption

WithLoginExprs implements login using Device (like telnet or console)

func WithManualAuth

func WithManualAuth() GenericCLIOption

WithManualAuth forces manual auth

func WithPager

func WithPager(pager expr.Expr) GenericCLIOption

WithPager implements pager

func WithQuestion

func WithQuestion(question expr.Expr) GenericCLIOption

WithQuestion implements question

func WithSFTPEnabled

func WithSFTPEnabled() GenericCLIOption

WithSFTPEnabled use sftp to download or upload

func WithWriteNewLine

func WithWriteNewLine(newline []byte) GenericCLIOption

type GenericDevice

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

func MakeGenericDevice

func MakeGenericDevice(cli GenericCLI, connector streamer.Connector, opts ...GenericDeviceOption) GenericDevice

func (*GenericDevice) Close

func (m *GenericDevice) Close()

func (*GenericDevice) Connect

func (m *GenericDevice) Connect(ctx context.Context) (err error)

func (*GenericDevice) Download

func (m *GenericDevice) Download(paths []string) (map[string]streamer.File, error)

func (*GenericDevice) Execute

func (m *GenericDevice) Execute(command cmd.Cmd) (cmd.CmdRes, error)

func (*GenericDevice) ExecuteBulk

func (m *GenericDevice) ExecuteBulk(commands []cmd.Cmd) ([]cmd.CmdRes, error)

func (*GenericDevice) GetAux

func (m *GenericDevice) GetAux() map[string]any

func (*GenericDevice) Upload

func (m *GenericDevice) Upload(paths map[string]streamer.File) error

type GenericDeviceOption

type GenericDeviceOption func(*GenericDevice)

func WithDevLogger

func WithDevLogger(logger *zap.Logger) GenericDeviceOption

Jump to

Keyboard shortcuts

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