arguments

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assemble

func Assemble(args []string) string

Assemble 根据参数数组组合成一行命令

func Parse

func Parse(line string) []string

Parse 把一行命令转换为参数数组

func UnwrapAll

func UnwrapAll(args []string) []string

UnwrapAll 把所有的参数解封装

Types

type Arguments

type Arguments interface {

	// 原始的未解析的参数
	Raw() []string

	// 命名选项
	Options() []Option

	// 未命名项
	Items() []Value

	GetItem(index int) Value

	GetOption(name string) Option
}

Arguments 表示一个命令模板,用来分析命令参数

type Option

type Option interface {
	Name() string
	Value(index int) Value
	Exists() bool
}

Option 表示一个带名称的选项

type Template

type Template interface {
	Parse(args []string) Arguments
}

Template 表示一个命令模板,用来分析命令参数

type TemplateBuilder

type TemplateBuilder interface {
	AcceptOption(name string, countValue int) TemplateBuilder
	Create() Template
}

TemplateBuilder 用来创建模板

func NewTemplateBuilder

func NewTemplateBuilder() TemplateBuilder

NewTemplateBuilder 新建一个 TemplateBuilder

type Value

type Value interface {
	Exists() bool
	String() string
	Boolean() bool
	Int() int
}

Value ... 表示一个简单的参数项

Jump to

Keyboard shortcuts

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