cmd

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: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

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

func NewAnswer

func NewAnswer(question, answer string) Answer

func (Answer) GetExpr

func (m Answer) GetExpr() expr.Expr

func (Answer) Match

func (m Answer) Match(question []byte) ([]byte, error)

type Cmd

type Cmd interface {
	GetCmdTimeout() time.Duration
	GetReadTimeout() time.Duration
	Value() []byte
	GetExprCallback() ([]string, map[string]string)
	QuestionHandler(question []byte) ([]byte, error)
	GetQuestionExprs() []expr.Expr
	ErrorHandler(error) error
	GetAgentForward() bool
}

func NewCmd

func NewCmd(command string, opts ...CmdOption) Cmd

func NewCmdList

func NewCmdList(commands []string, opts ...CmdOption) []Cmd

type CmdImpl

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

func (CmdImpl) ErrorHandler

func (m CmdImpl) ErrorHandler(err error) error

func (CmdImpl) GetAgentForward

func (m CmdImpl) GetAgentForward() bool

func (CmdImpl) GetCmdTimeout

func (m CmdImpl) GetCmdTimeout() time.Duration

func (CmdImpl) GetExprCallback

func (m CmdImpl) GetExprCallback() ([]string, map[string]string)

func (CmdImpl) GetQuestionExprs

func (m CmdImpl) GetQuestionExprs() []expr.Expr

func (CmdImpl) GetReadTimeout

func (m CmdImpl) GetReadTimeout() time.Duration

func (CmdImpl) QuestionHandler

func (m CmdImpl) QuestionHandler(question []byte) ([]byte, error)

func (CmdImpl) Value

func (m CmdImpl) Value() []byte

type CmdOption

type CmdOption func(*CmdImpl)

func WithAnswers

func WithAnswers(answers ...Answer) CmdOption

func WithCmdTimeout

func WithCmdTimeout(timeout time.Duration) CmdOption

func WithErrorIgnore

func WithErrorIgnore() CmdOption

func WithExprCallback

func WithExprCallback(exprCallbacks ...ExprCallback) CmdOption

func WithForwarding

func WithForwarding(forward bool) CmdOption

func WithReadTimeout

func WithReadTimeout(timeout time.Duration) CmdOption

type CmdRes

type CmdRes interface {
	Output() []byte
	Error() []byte
	Status() int
	SetExtra(string, interface{})
	GetExtra(string) (interface{}, bool)
}

func NewCmdRes

func NewCmdRes(output []byte) CmdRes

func NewCmdResFull

func NewCmdResFull(output, err []byte, status int, extra map[string]interface{}) CmdRes

type CmdResList

type CmdResList []CmdRes

func (CmdResList) Output

func (m CmdResList) Output() []byte

func (CmdResList) ToCmdRes

func (m CmdResList) ToCmdRes() CmdRes

type ExprCallback

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

func NewExprCallback

func NewExprCallback(expr, write string) ExprCallback

type Res

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

func (*Res) Error

func (m *Res) Error() []byte

func (*Res) GetExtra

func (m *Res) GetExtra(key string) (interface{}, bool)

func (*Res) Output

func (m *Res) Output() []byte

func (*Res) SetExtra

func (m *Res) SetExtra(key string, value interface{})

func (*Res) Status

func (m *Res) Status() int

Jump to

Keyboard shortcuts

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