cmd

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmds []Cmd

Functions

func ListCommand

func ListCommand()

命令列表

func ParseToKV

func ParseToKV(args ...string) (map[string]string, []string)

func RegisterCommand

func RegisterCommand(cmd Cmd)

注册命令

func RunCmd

func RunCmd(cmd string, arg ...string) error

func SortArgs

func SortArgs(args ...string) []string

Types

type ClientCmd

type ClientCmd struct {
	*flag.FlagSet
	Addr string
}

ClientCmd 结构体,包含一个 FlagSet 和一个 Addr 字段

func (*ClientCmd) Init

func (c *ClientCmd) Init(arg ...string) error

初始化命令,设置 FlagSet 和 Addr 字段

func (*ClientCmd) Name

func (*ClientCmd) Name() []string

返回命令的名称

func (*ClientCmd) Run

func (s *ClientCmd) Run() error

运行命令,打印 Addr 字段

func (*ClientCmd) Usage

func (c *ClientCmd) Usage()

打印命令的详细描述

func (*ClientCmd) UsageShort

func (c *ClientCmd) UsageShort() string

返回命令的简短描述

type Cmd

type Cmd interface {
	// 定位命令
	Name() []string
	// 初始化命令
	Init(arg ...string) error
	// 短的帮助信息 用于命令行送显
	UsageShort() string
	// 自动生成的帮助信息
	Usage()
	// 执行
	Run() error
}

type HideModel

type HideModel interface {
	Hide() bool
}

type ServerCmd

type ServerCmd struct {
	*flag.FlagSet
	Port string
}

ServerCmd 结构体,包含一个 FlagSet 和一个 Port 字段

func (*ServerCmd) Init

func (c *ServerCmd) Init(arg ...string) error

初始化命令,设置 FlagSet 和 Port 字段的值

func (*ServerCmd) Name

func (*ServerCmd) Name() []string

返回命令的名称

func (*ServerCmd) Run

func (s *ServerCmd) Run() error

运行命令,打印 Port 字段的值

func (*ServerCmd) Usage

func (c *ServerCmd) Usage()

打印命令的详细描述

func (*ServerCmd) UsageShort

func (c *ServerCmd) UsageShort() string

返回命令的简短描述

Jump to

Keyboard shortcuts

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