contract

package
v0.0.0-...-23ffe2c Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseInputHas = map[string]ArgParam{
	"-d": {Name: "-d", Description: "守护进程启动"},
	"-h": {Name: "-h", Description: "显示帮助信息"},
}

Functions

This section is empty.

Types

type ArgArgument

type ArgArgument struct {
	Name        string // 名称
	Description string // 说明
}

参数存储

type ArgParam

type ArgParam struct {
	Name        string // 名称
	Description string // 说明
	Default     string // 默认值
}

参数存储

type Argument

type Argument struct {
	// 是否有参数 【名称string】
	Has []ArgParam
	// 必须输入参数 【命令位置】【赋值名称】默认值
	Argument []ArgArgument
	// 可选输入参数 【赋值名称(开头必须是-)】默认值
	Option []ArgParam
}

参数设置结构

type Command

type Command interface {
	Configure() Configure
	Execute(input Input)
}

type Config

type Config interface {
}

type Configure

type Configure struct {
	// 说明
	Description string
	// 输入定义
	Input Argument
}

type Console

type Console interface {
	Init()
	HasCommand() bool
	RunCommand() error
	RunCommandHelp(name string, configure Configure) error
	RunHelp()
}

type Help

type Help interface {
	Configure() Configure
	Execute(input Input)
	HelpExecute(con Configure)
}

type Input

type Input struct {
	// 是否有参数 【名称string】默认值bool
	Has map[string]bool
	// 必须输入参数 【命令位置】【赋值名称】默认值
	Argument map[string]string
	// 可选输入参数 【赋值名称(开头必须是-)】默认值
	Option map[string]string
}

参数操作

func (*Input) GetArgument

func (i *Input) GetArgument(key string) string

参数

func (*Input) GetHas

func (i *Input) GetHas(key string) bool

参数

func (*Input) GetOption

func (i *Input) GetOption(key string) string

参数

func (*Input) IsDaemon

func (i *Input) IsDaemon() bool

是否后台启动

func (*Input) Parsed

func (i *Input) Parsed(Config Argument) error

参数解析

type MapCommand

type MapCommand struct {
	Command       Command
	CommandConfig Configure
}

Jump to

Keyboard shortcuts

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