command

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheData

type CacheData struct {
	CreateAt time.Time `json:"create_at"`
	Data     []byte    `json:"data"`
}

func NewCacheData

func NewCacheData(data []byte) *CacheData

func (*CacheData) IsTimeout

func (cd *CacheData) IsTimeout() bool

type CliCmd

type CliCmd struct {
	Force bool
	// contains filtered or unexported fields
}

func NewCliCmd

func NewCliCmd(cmd, key string, timeout int, force bool) *CliCmd

func (*CliCmd) CacheData

func (cc *CliCmd) CacheData() *CacheData

func (*CliCmd) Cmd

func (cc *CliCmd) Cmd() string

func (*CliCmd) Id

func (cc *CliCmd) Id(ip string) string

func (*CliCmd) Ip

func (cc *CliCmd) Ip() string

func (*CliCmd) Key

func (cc *CliCmd) Key() string

func (*CliCmd) Level

func (cc *CliCmd) Level() CommandLevel

func (*CliCmd) Msg

func (cc *CliCmd) Msg() string

func (*CliCmd) Ok

func (cc *CliCmd) Ok() bool

func (*CliCmd) SetCacheData

func (cc *CliCmd) SetCacheData(data *CacheData)

func (*CliCmd) Timeout

func (cc *CliCmd) Timeout() int

func (*CliCmd) WithIp

func (cc *CliCmd) WithIp(ip string) *CliCmd

func (*CliCmd) WithLevel

func (cc *CliCmd) WithLevel(level CommandLevel)

func (*CliCmd) WithMsg

func (cc *CliCmd) WithMsg(msg string)

func (*CliCmd) WithOk

func (cc *CliCmd) WithOk(ok bool)

type CliCmdList

type CliCmdList struct {
	Cmds  []Command `json:"Cmds"`
	Ip    string    `json:"Ip"`
	Force bool      `json:"Force"`
}

func NewCliCmdList

func NewCliCmdList(ip string, force bool) *CliCmdList

func (*CliCmdList) Add

func (cl *CliCmdList) Add(cmd, key string, timeout int, force bool)

func (*CliCmdList) AddCmd

func (cl *CliCmdList) AddCmd(cmd Command)

func (*CliCmdList) Assist

func (cl *CliCmdList) Assist() (cmdList []Command, total, success, failed int)

func (*CliCmdList) Cmd

func (cl *CliCmdList) Cmd(key string) Command

func (*CliCmdList) Color

func (*CliCmdList) Error

func (cl *CliCmdList) Error() error

func (*CliCmdList) Get

func (cl *CliCmdList) Get(key string) (cd *CacheData, err error)

func (*CliCmdList) Id

func (cl *CliCmdList) Id(ip string) string

func (*CliCmdList) KeyExist

func (cl *CliCmdList) KeyExist(key string) bool

func (*CliCmdList) MainCmds

func (cl *CliCmdList) MainCmds() (cmdList []Command, total, success, failed int)

func (*CliCmdList) Table

func (cl *CliCmdList) Table() *tools.Table

type CmdExecuteStatus

type CmdExecuteStatus interface {
	Color() global.CmdExecuteStatusColor
	MainCmds() (cmdList []Command, total, success, failed int)
	Assist() (cmdList []Command, total, success, failed int)
	Error() error
	Cmd(key string) Command
}

type CmdList

type CmdList interface {
	Table() *tools.Table
	AddCmd(cmd Command)
	Get(key string) (cd *CacheData, err error)
}

type Command

type Command interface {
	// run() *session.CacheData
	Id(ip string) string
	SetCacheData(data *CacheData)
	CacheData() *CacheData
	Msg() string
	WithMsg(msg string)
	Timeout() int
	Key() string
	Cmd() string
	WithLevel(CommandLevel)
	Level() CommandLevel
	WithOk(bool)
	Ok() bool
}

type CommandLevel

type CommandLevel int
const (
	OPTION CommandLevel = iota
	MUST
)

type HttpCmd

type HttpCmd struct {
	Method string
	Ip     string
	Url    string

	Data []byte

	Force bool
	// contains filtered or unexported fields
}

func NewHttpCmd

func NewHttpCmd(method, url, key string, timeout int, force bool) *HttpCmd

func (*HttpCmd) CacheData

func (hc *HttpCmd) CacheData() *CacheData

func (*HttpCmd) Cmd

func (hc *HttpCmd) Cmd() string

func (*HttpCmd) Id

func (hc *HttpCmd) Id(ip string) string

func (*HttpCmd) Key

func (hc *HttpCmd) Key() string

func (*HttpCmd) Level

func (hc *HttpCmd) Level() CommandLevel

func (HttpCmd) MarshalJSON

func (cmd HttpCmd) MarshalJSON() ([]byte, error)

func (*HttpCmd) Msg

func (hc *HttpCmd) Msg() string

func (*HttpCmd) Ok

func (hc *HttpCmd) Ok() bool

func (*HttpCmd) SetCacheData

func (hc *HttpCmd) SetCacheData(data *CacheData)

func (*HttpCmd) Timeout

func (hc *HttpCmd) Timeout() int

func (*HttpCmd) WithData

func (hc *HttpCmd) WithData(data []byte) *HttpCmd

func (*HttpCmd) WithIp

func (hc *HttpCmd) WithIp(ip string) *HttpCmd

func (*HttpCmd) WithLevel

func (hc *HttpCmd) WithLevel(level CommandLevel)

func (*HttpCmd) WithMsg

func (hc *HttpCmd) WithMsg(msg string)

func (*HttpCmd) WithOk

func (hc *HttpCmd) WithOk(ok bool)

type HttpCmdList

type HttpCmdList struct {
	Clis  []string  `json:"clis"`
	Cmds  []Command `json:"Cmds"`
	Ip    string    `json:"Ip"`
	Force bool      `json:"Force"`
}

func NewHttpCmdList

func NewHttpCmdList(ip string, force bool) *HttpCmdList

func (*HttpCmdList) Add

func (cl *HttpCmdList) Add(method, url string, data []byte, timeout int, force bool)

func (*HttpCmdList) AddCli

func (cl *HttpCmdList) AddCli(cli string)

func (*HttpCmdList) AddCmd

func (cl *HttpCmdList) AddCmd(cmd Command)

func (*HttpCmdList) Assist

func (cl *HttpCmdList) Assist() (cmdList []Command, total, success, failed int)

func (*HttpCmdList) Cmd

func (cl *HttpCmdList) Cmd(key string) Command

func (*HttpCmdList) Color

func (*HttpCmdList) Error

func (cl *HttpCmdList) Error() error

func (*HttpCmdList) Get

func (cl *HttpCmdList) Get(key string) (cd *CacheData, err error)

func (*HttpCmdList) Id

func (cl *HttpCmdList) Id(ip string) string

func (*HttpCmdList) MainCmds

func (cl *HttpCmdList) MainCmds() (cmdList []Command, total, success, failed int)

func (*HttpCmdList) Table

func (cl *HttpCmdList) Table() *tools.Table

type NetconfCmd

type NetconfCmd struct {
	netconf.RPCMessage
	Ip string

	Lock  bool
	Force bool
	// contains filtered or unexported fields
}

func NewNetconfCmd

func NewNetconfCmd(timeout int, lock bool, key string, force bool) *NetconfCmd

func (*NetconfCmd) AppendCustomAttrs

func (nc *NetconfCmd) AppendCustomAttrs(attr string, truncate bool) *NetconfCmd

func (*NetconfCmd) AppendMethod

func (nc *NetconfCmd) AppendMethod(method netconf.RawMethod, truncate bool) *NetconfCmd

func (*NetconfCmd) AppendXmlns

func (nc *NetconfCmd) AppendXmlns(xmlns string, truncate bool) *NetconfCmd

func (*NetconfCmd) CacheData

func (nc *NetconfCmd) CacheData() *CacheData

func (*NetconfCmd) Cmd

func (nc *NetconfCmd) Cmd() string

func (*NetconfCmd) DisableHeader

func (nc *NetconfCmd) DisableHeader() *NetconfCmd

func (*NetconfCmd) Id

func (nc *NetconfCmd) Id(ip string) string

func (*NetconfCmd) Key

func (nc *NetconfCmd) Key() string

func (*NetconfCmd) Level

func (nc *NetconfCmd) Level() CommandLevel

func (*NetconfCmd) Msg

func (nc *NetconfCmd) Msg() string

func (*NetconfCmd) Ok

func (nc *NetconfCmd) Ok() bool

func (*NetconfCmd) SetCacheData

func (nc *NetconfCmd) SetCacheData(data *CacheData)

func (*NetconfCmd) Timeout

func (nc *NetconfCmd) Timeout() int

func (*NetconfCmd) WithInnerXML

func (nc *NetconfCmd) WithInnerXML(xml []byte) *NetconfCmd

func (*NetconfCmd) WithLevel

func (nc *NetconfCmd) WithLevel(level CommandLevel)

func (*NetconfCmd) WithMsg

func (nc *NetconfCmd) WithMsg(msg string)

func (*NetconfCmd) WithOk

func (nc *NetconfCmd) WithOk(ok bool)

type SnmpCmd

type SnmpCmd struct {
	Oid string

	Ip string

	Force bool
	Plan  *SnmpPlan
	// contains filtered or unexported fields
}

func NewSnmpCmd

func NewSnmpCmd(oid, key string, timeout int, force bool) *SnmpCmd

func (*SnmpCmd) CacheData

func (sc *SnmpCmd) CacheData() *CacheData

func (*SnmpCmd) Cmd

func (sc *SnmpCmd) Cmd() string

func (*SnmpCmd) Id

func (sc *SnmpCmd) Id(ip string) string

func (*SnmpCmd) Key

func (sc *SnmpCmd) Key() string

func (*SnmpCmd) Level

func (sc *SnmpCmd) Level() CommandLevel

func (*SnmpCmd) Msg

func (sc *SnmpCmd) Msg() string

func (*SnmpCmd) Ok

func (sc *SnmpCmd) Ok() bool

func (*SnmpCmd) SetCacheData

func (sc *SnmpCmd) SetCacheData(data *CacheData)

func (*SnmpCmd) SetPlan

func (sc *SnmpCmd) SetPlan(plan *SnmpPlan) *SnmpCmd

func (*SnmpCmd) Timeout

func (sc *SnmpCmd) Timeout() int

func (*SnmpCmd) WithLevel

func (sc *SnmpCmd) WithLevel(level CommandLevel)

func (*SnmpCmd) WithMsg

func (sc *SnmpCmd) WithMsg(msg string)

func (*SnmpCmd) WithOk

func (sc *SnmpCmd) WithOk(ok bool)

type SnmpPlan

type SnmpPlan struct {
	Index         []int
	Prefix        []int
	PrefixMap     map[string]string
	PrefixCallMap map[string]func(byte, string, interface{}) (result string, err error)
	IndexCall     func(string) (result string, err error)
}

func NewSnmpPlan

func NewSnmpPlan(index, prefix []int) *SnmpPlan

func (*SnmpPlan) WithIndexCall

func (sp *SnmpPlan) WithIndexCall(indexCall func(string) (result string, err error)) *SnmpPlan

func (*SnmpPlan) WithPrefixCallMap

func (sp *SnmpPlan) WithPrefixCallMap(prefixCallMap map[string]func(byte, string, interface{}) (result string, err error)) *SnmpPlan

func (*SnmpPlan) WithPrefixMap

func (sp *SnmpPlan) WithPrefixMap(prefixMap map[string]string) *SnmpPlan

Jump to

Keyboard shortcuts

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