Documentation ¶
Overview ¶
Package cmd describes command and command result interface and implementations.
Index ¶
- Variables
- type Answer
- type Cmd
- type CmdImpl
- func (m CmdImpl) ErrorHandler(err error) error
- func (m CmdImpl) GetAgentForward() bool
- func (m CmdImpl) GetCmdTimeout() time.Duration
- func (m CmdImpl) GetExprCallback() ([]string, map[string]string)
- func (m CmdImpl) GetQuestionExprs() []expr.Expr
- func (m CmdImpl) GetReadTimeout() time.Duration
- func (m CmdImpl) QuestionHandler(question []byte) ([]byte, error)
- func (m CmdImpl) Value() []byte
- type CmdOption
- type CmdRes
- type ExprCallback
- type Res
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFoundAnswer = errors.New("not found answer")
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd interface { // GetCmdTimeout returns command timeout GetCmdTimeout() time.Duration // GetReadTimeout returns timeout between sequential reads GetReadTimeout() time.Duration // Value returns command value Value() []byte // GetExprCallback returns mapping of expressions and callbacks // to call if matched. GetExprCallback() ([]string, map[string]string) // QuestionHandler is called when question is matched. QuestionHandler(question []byte) ([]byte, error) // GetQuestionExprs returns list of possible questions. GetQuestionExprs() []expr.Expr // ErrorHandler is called when where is an error found in output. ErrorHandler(error) error // GetAgentForward returns whether SSH agent should be forwarded during execution. GetAgentForward() bool }
Cmd is an interface for command.
func NewCmdList ¶
type CmdImpl ¶
type CmdImpl struct {
// contains filtered or unexported fields
}
CmdImpl implements Cmd interface.
func (CmdImpl) ErrorHandler ¶
func (CmdImpl) GetAgentForward ¶
func (CmdImpl) GetCmdTimeout ¶
func (CmdImpl) GetQuestionExprs ¶
func (CmdImpl) GetReadTimeout ¶
type CmdOption ¶
type CmdOption func(*CmdImpl)
func WithAnswers ¶
func WithCmdTimeout ¶
func WithErrorIgnore ¶
func WithErrorIgnore() CmdOption
func WithExprCallback ¶
func WithExprCallback(exprCallbacks ...ExprCallback) CmdOption
func WithForwarding ¶
func WithReadTimeout ¶
type CmdRes ¶
type CmdRes interface { Output() []byte Error() []byte Status() int SetExtra(string, interface{}) GetExtra(string) (interface{}, bool) }
CmdRes is an interface for command result.
type ExprCallback ¶
type ExprCallback struct {
// contains filtered or unexported fields
}
func NewExprCallback ¶
func NewExprCallback(expr, write string) ExprCallback
Click to show internal directories.
Click to hide internal directories.