Documentation ¶
Overview ¶
Package genericcli implements Device interface using regular expressions.
Index ¶
- Constants
- Variables
- func GenericExecute(command cmd.Cmd, connector streamer.Connector, cli GenericCLI) (cmd.CmdRes, error)
- type GenericCLI
- type GenericCLIOption
- func WithAnswers(answers []cmd.Answer) GenericCLIOption
- func WithAutoCommands(commands []cmd.Cmd) GenericCLIOption
- func WithCredentialInterceptor(inter func(credentials.Credentials) credentials.Credentials) GenericCLIOption
- func WithEchoExprFn(fn func(cmd.Cmd) expr.Expr) GenericCLIOption
- func WithInitialWait(duration time.Duration) GenericCLIOption
- func WithLoginExprs(login, password, passwordError expr.Expr) GenericCLIOption
- func WithManualAuth() GenericCLIOption
- func WithPager(pager expr.Expr) GenericCLIOption
- func WithQuestion(question expr.Expr) GenericCLIOption
- func WithSFTPEnabled() GenericCLIOption
- func WithTerminalParams(width, height int) GenericCLIOption
- func WithWriteNewLine(newline []byte) GenericCLIOption
- type GenericDevice
- func (m *GenericDevice) Close()
- func (m *GenericDevice) Connect(ctx context.Context) (err error)
- func (m *GenericDevice) Download(paths []string) (map[string]streamer.File, error)
- func (m *GenericDevice) Execute(command cmd.Cmd) (cmd.CmdRes, error)
- func (m *GenericDevice) ExecuteBulk(commands []cmd.Cmd) ([]cmd.CmdRes, error)
- func (m *GenericDevice) GetAuthError() expr.Expr
- func (m *GenericDevice) GetAux() map[string]any
- func (m *GenericDevice) GetLogin() expr.Expr
- func (m *GenericDevice) GetPassword() expr.Expr
- func (m *GenericDevice) GetPrompt() expr.Expr
- func (m *GenericDevice) Upload(paths map[string]streamer.File) error
- type GenericDeviceOption
- type GetAllRegex
- type SetTerminalSize
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 ¶
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 WithCredentialInterceptor ¶
func WithCredentialInterceptor(inter func(credentials.Credentials) credentials.Credentials) GenericCLIOption
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 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) ExecuteBulk ¶
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
type GenericDeviceOption ¶
type GenericDeviceOption func(*GenericDevice)
func WithDevLogger ¶
func WithDevLogger(logger *zap.Logger) GenericDeviceOption
type GetAllRegex ¶ added in v1.0.10
type SetTerminalSize ¶ added in v1.0.11
Click to show internal directories.
Click to hide internal directories.