genericcli

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Overview

Package genericcli implements Device interface using regular expressions.

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 WithInitialWait added in v1.0.14

func WithInitialWait(duration time.Duration) GenericCLIOption

WithInitialWait sets sleep duration before first reading after login

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 WithTerminalParams added in v1.0.11

func WithTerminalParams(width, height int) GenericCLIOption

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) GetAuthError added in v1.0.13

func (m *GenericDevice) GetAuthError() expr.Expr

func (*GenericDevice) GetAux

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

func (*GenericDevice) GetLogin added in v1.0.10

func (m *GenericDevice) GetLogin() expr.Expr

func (*GenericDevice) GetPassword added in v1.0.10

func (m *GenericDevice) GetPassword() expr.Expr

func (*GenericDevice) GetPrompt added in v1.0.10

func (m *GenericDevice) GetPrompt() expr.Expr

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

type GetAllRegex added in v1.0.10

type GetAllRegex interface {
	GetLogin() expr.Expr
	GetPassword() expr.Expr
	GetAuthError() expr.Expr
	GetPrompt() expr.Expr
}

type SetTerminalSize added in v1.0.11

type SetTerminalSize interface {
	SetTerminalSize(w int, h int)
}

Jump to

Keyboard shortcuts

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