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 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 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) GetAux() map[string]any
- func (m *GenericDevice) Upload(paths map[string]streamer.File) error
- type GenericDeviceOption
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 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 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) GetAux ¶
func (m *GenericDevice) GetAux() map[string]any
type GenericDeviceOption ¶
type GenericDeviceOption func(*GenericDevice)
func WithDevLogger ¶
func WithDevLogger(logger *zap.Logger) GenericDeviceOption
Click to show internal directories.
Click to hide internal directories.