cmds

package
v0.3.37 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Cmd_Shell  = "shell"
	Cmd_Expect = "expect"
)
View Source
const (
	CMD_ERROR_PARAM_LEN = iota
	CMD_ERROR_PARAM_TYPE
)

Variables

This section is empty.

Functions

func GetAllCmds

func GetAllCmds() map[string]*WrappedCmd

func RegisterCmd

func RegisterCmd(s string, cmd *WrappedCmd)

func SplitCommandParams

func SplitCommandParams(cmd string) (string, []string)

Types

type CmdError

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

func NewCmdError

func NewCmdError(errType int, cmd string, offset int, typ string) *CmdError

func (*CmdError) Error

func (this *CmdError) Error() string

type CmdHandler

type CmdHandler func(CmdOutput) *CmdResult

type CmdOutput

type CmdOutput []string

func (CmdOutput) LastOutput

func (this CmdOutput) LastOutput() string

type CmdResult

type CmdResult struct {
	Outputs []string
	Success bool
	Results map[string]interface{}
}

type CmdType

type CmdType string

func (CmdType) GetCmdPrefix

func (this CmdType) GetCmdPrefix() string

type Command

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

func (*Command) ConsoleExec

func (this *Command) ConsoleExec(param *ParamsValue, console IConsole) *promise.Promise[interface{}]

func (*Command) Exec

func (this *Command) Exec(params ...interface{}) *promise.Promise[interface{}]

func (*Command) ExecWithConsole

func (this *Command) ExecWithConsole(console IConsole, params ...interface{}) *promise.Promise[interface{}]

func (*Command) Name

func (this *Command) Name() string

func (*Command) SetConsole

func (this *Command) SetConsole(console IConsole)

func (*Command) Tips

func (this *Command) Tips() string

type ICommand

type ICommand interface {
	Name() string
	SetConsole(IConsole)
	ConsoleExec(param *ParamsValue, console IConsole) *promise.Promise[interface{}]
	ExecWithConsole(console IConsole, params ...interface{}) *promise.Promise[interface{}]
	Exec(params ...interface{}) *promise.Promise[interface{}]
	Tips() string
}

func NewCommand

func NewCommand(name string, tips string, f func(value *ParamsValue, console IConsole) *promise.Promise[interface{}], console IConsole) ICommand

func NewCommandNoConsole

func NewCommandNoConsole(name string, tips string, f func(value *ParamsValue, console IConsole) *promise.Promise[interface{}]) ICommand

type ICommandSender

type ICommandSender interface {
	SendCmd(string)
	OnSelect()
	OnDeselect()
}

type IConsole

type IConsole interface {
	log.Hook
	log.ILogger
	Write(p []byte) (int, error)
	Clear()
}

type ParamsValue

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

func NewParamsValue

func NewParamsValue(cmd string, value ...interface{}) *ParamsValue

func (*ParamsValue) Bool

func (this *ParamsValue) Bool() bool

func (*ParamsValue) BoolOpt

func (this *ParamsValue) BoolOpt() bool

func (*ParamsValue) Clone added in v0.1.30

func (this *ParamsValue) Clone() *ParamsValue

func (*ParamsValue) Float

func (this *ParamsValue) Float() float64

func (*ParamsValue) FloatOpt

func (this *ParamsValue) FloatOpt() float64

func (*ParamsValue) ForceString added in v0.1.30

func (this *ParamsValue) ForceString() string

func (*ParamsValue) Int

func (this *ParamsValue) Int() int

func (*ParamsValue) Int32

func (this *ParamsValue) Int32() int32

func (*ParamsValue) Int32Opt

func (this *ParamsValue) Int32Opt() int32

func (*ParamsValue) Int64

func (this *ParamsValue) Int64() int64

func (*ParamsValue) Int64Opt

func (this *ParamsValue) Int64Opt() int64

func (*ParamsValue) IntOpt

func (this *ParamsValue) IntOpt() int

func (*ParamsValue) IsHelp

func (this *ParamsValue) IsHelp() bool

func (*ParamsValue) LeftParams

func (this *ParamsValue) LeftParams() []interface{}

func (*ParamsValue) Len

func (this *ParamsValue) Len() int

func (*ParamsValue) String

func (this *ParamsValue) String() string

func (*ParamsValue) StringOpt

func (this *ParamsValue) StringOpt() string

type WrappedCmd

type WrappedCmd struct {
	CmdString  string
	Tips       string
	ParamsNum  int
	ParamsMap  []string
	CmdType    CmdType
	CmdHandler CmdHandler
}

func GetCmdByName

func GetCmdByName(s string) *WrappedCmd

func (*WrappedCmd) FillParams

func (this *WrappedCmd) FillParams(param ...string) string

Jump to

Keyboard shortcuts

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