cmd

package
v0.0.0-...-7647e70 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllCommands

func AllCommands() map[string]CommandInterface

func ParseArgs

func ParseArgs(s string) (args []string)

分析字符串中的参数

func Register

func Register(cmdPtr interface{})

func Run

func Run(code string) error

func Try

func Try(args []string) bool

尝试执行命令行

Types

type Command

type Command struct {
	SubCodeString string
}

func (*Command) Arg

func (this *Command) Arg(index int) (value string, found bool)

func (*Command) Error

func (this *Command) Error(err error)

func (*Command) ErrorString

func (this *Command) ErrorString(err string)

func (*Command) HasParam

func (this *Command) HasParam(key string) bool

判断是否含有某参数

func (*Command) Output

func (this *Command) Output(message ...interface{})

func (*Command) Param

func (this *Command) Param(key string) (value string, found bool)

获取参数值

func (*Command) Printf

func (this *Command) Printf(format string, args ...interface{})

func (*Command) Println

func (this *Command) Println(message ...interface{})

func (*Command) SubCode

func (this *Command) SubCode() string

type CommandInterface

type CommandInterface interface {
	Name() string
	Usage() string
	Codes() []string
	SubCode() string
	Run()
}

type HelpCommand

type HelpCommand struct {
	*Command
}

命令帮助

func (*HelpCommand) Codes

func (this *HelpCommand) Codes() []string

func (*HelpCommand) Name

func (this *HelpCommand) Name() string

func (*HelpCommand) Run

func (this *HelpCommand) Run()

func (*HelpCommand) Usage

func (this *HelpCommand) Usage() string

type QuitCommand

type QuitCommand struct {
	*Command
}

退出命令

func (*QuitCommand) Codes

func (this *QuitCommand) Codes() []string

func (*QuitCommand) Name

func (this *QuitCommand) Name() string

func (*QuitCommand) Run

func (this *QuitCommand) Run()

func (*QuitCommand) Usage

func (this *QuitCommand) Usage() string

Jump to

Keyboard shortcuts

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