cli

package
v0.0.0-...-95960de Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CliDefaultClientStart

func CliDefaultClientStart() bool

func CliDoClient

func CliDoClient(host string, args []string)

CliDoClient 命令行客户端

func CliDoClientOutput

func CliDoClientOutput(host string, args []string, timeoutMs int) (string, error)

CliDoClientOutput CliDoClientOutput

func GetVarType

func GetVarType(e interface{}) string

GetVarType GetVarType

func InitCliCmd

func InitCliCmd(cli *CliServer)

InitCliCmd 初始化默认的命令

Types

type CliCallback

type CliCallback func(cli *CliServer, buffer *bytes.Buffer, args []string) int

type CliServer

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

func CliDefaultServerStart

func CliDefaultServerStart(beforeStart func(cli *CliServer)) *CliServer

func NewCliServer

func NewCliServer(port int) (*CliServer, error)

NewCliServer 新建一个命令行

func (*CliServer) AddCmd

func (me *CliServer) AddCmd(parent *CmdItem, cmdName, cmdComment string, cmdFunc CliCallback, data ...interface{}) *CmdItem

AddCmd 添加命令行

func (*CliServer) Close

func (me *CliServer) Close()

Close 关闭

func (*CliServer) GetCmdData

func (me *CliServer) GetCmdData() interface{}

GetCmdData 获取当前执行命令行的用户数据

func (*CliServer) Handle

func (me *CliServer) Handle() error

Handle 处理命令行消息

func (*CliServer) Output

func (me *CliServer) Output(buffer *bytes.Buffer, str string)

Output 输出命令信息

func (*CliServer) PrintUsage

func (me *CliServer) PrintUsage(buffer *bytes.Buffer)

PrintUsage 打印帮助信息

func (*CliServer) SetReadTimeout

func (me *CliServer) SetReadTimeout(v int)

func (*CliServer) Start

func (me *CliServer) Start()

Start 后台运行命令行服务

type CmdItem

type CmdItem struct {
	CmdName    string
	CmdComment string
	Func       CliCallback
	Childs     *list.List
	UserData   interface{}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳