Documentation
¶
Index ¶
- func SetupConsole(ctx lang.Context, factory ConsoleFactory) error
- type Client
- type CommandHelpInfo
- type CommandHelper
- type Console
- type ConsoleFactory
- type DefaultClient
- func (inst *DefaultClient) Execute(t *Task) error
- func (inst *DefaultClient) ExecuteAsync(t *Task) task.Promise
- func (inst *DefaultClient) ExecuteScript(command string) error
- func (inst *DefaultClient) ExecuteScriptAsync(command string) task.Promise
- func (inst *DefaultClient) ExecuteWithArguments(args []string) error
- func (inst *DefaultClient) ExecuteWithArgumentsAsync(args []string) task.Promise
- type DefaultSerivce
- func (inst *DefaultSerivce) AddFilter(priority int, filter Filter) error
- func (inst *DefaultSerivce) FindHandler(name string) (Handler, error)
- func (inst *DefaultSerivce) GetClient() Client
- func (inst *DefaultSerivce) GetFilterChain() FilterChain
- func (inst *DefaultSerivce) GetHandlerNames() []string
- func (inst *DefaultSerivce) Init() error
- func (inst *DefaultSerivce) RegisterHandler(name string, h Handler) error
- type Filter
- type FilterChain
- type FilterChainBuilder
- type Handler
- type Service
- type Task
- type TaskContext
- type TaskUnit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetupConsole ¶ added in v0.0.56
func SetupConsole(ctx lang.Context, factory ConsoleFactory) error
SetupConsole 从上下文取控制台接口
Types ¶
type Client ¶
type Client interface {
Execute(task *Task) error
ExecuteScript(script string) error
ExecuteWithArguments(args []string) error
ExecuteAsync(task *Task) task.Promise
ExecuteScriptAsync(script string) task.Promise
ExecuteWithArgumentsAsync(args []string) task.Promise
}
Client 是用于执行命令的 API
type CommandHelpInfo ¶ added in v0.0.56
CommandHelpInfo 是命令的帮助信息
type CommandHelper ¶ added in v0.0.56
type CommandHelper interface {
GetHelpInfo() *CommandHelpInfo
}
CommandHelper 是命令的帮助信息提供者, 通常与Handler 实现于同一个结构
type Console ¶ added in v0.0.56
type Console interface {
GetWD() string
SetWD(wd string)
GetWorkingPath() fs.Path
SetWorkingPath(wd fs.Path)
Error() io.Writer
Output() io.Writer
Input() io.Reader
SetError(w io.Writer)
SetOutput(w io.Writer)
SetInput(r io.Reader)
}
Console 接口表示一个跟上下文绑定的控制台
type ConsoleFactory ¶ added in v0.0.56
type ConsoleFactory interface {
Create() Console
}
ConsoleFactory 是创建 Console 的工厂
type DefaultClient ¶ added in v0.0.56
type DefaultClient struct {
markup.Component `id:"cli-client" class:"cli-client"`
Service Service `inject:"#cli-service"`
}
DefaultClient 执行命令的客户端
func (*DefaultClient) Execute ¶ added in v0.0.56
func (inst *DefaultClient) Execute(t *Task) error
Execute todo...
func (*DefaultClient) ExecuteAsync ¶ added in v0.0.56
func (inst *DefaultClient) ExecuteAsync(t *Task) task.Promise
ExecuteAsync todo...
func (*DefaultClient) ExecuteScript ¶ added in v0.0.56
func (inst *DefaultClient) ExecuteScript(command string) error
ExecuteScript todo...
func (*DefaultClient) ExecuteScriptAsync ¶ added in v0.0.56
func (inst *DefaultClient) ExecuteScriptAsync(command string) task.Promise
ExecuteScriptAsync todo...
func (*DefaultClient) ExecuteWithArguments ¶ added in v0.0.56
func (inst *DefaultClient) ExecuteWithArguments(args []string) error
ExecuteWithArguments todo...
func (*DefaultClient) ExecuteWithArgumentsAsync ¶ added in v0.0.56
func (inst *DefaultClient) ExecuteWithArgumentsAsync(args []string) task.Promise
ExecuteWithArgumentsAsync todo...
type DefaultSerivce ¶ added in v0.0.56
type DefaultSerivce struct {
markup.Component `id:"cli-service" initMethod:"Init"`
Filters []Filter `inject:"cli-filter"`
Handlers []Handler `inject:"cli-handler"`
// contains filtered or unexported fields
}
DefaultSerivce 是默认的 CLI 服务
func (*DefaultSerivce) AddFilter ¶ added in v0.0.56
func (inst *DefaultSerivce) AddFilter(priority int, filter Filter) error
func (*DefaultSerivce) FindHandler ¶ added in v0.0.56
func (inst *DefaultSerivce) FindHandler(name string) (Handler, error)
func (*DefaultSerivce) GetClient ¶ added in v0.0.56
func (inst *DefaultSerivce) GetClient() Client
func (*DefaultSerivce) GetFilterChain ¶ added in v0.0.56
func (inst *DefaultSerivce) GetFilterChain() FilterChain
func (*DefaultSerivce) GetHandlerNames ¶ added in v0.0.56
func (inst *DefaultSerivce) GetHandlerNames() []string
func (*DefaultSerivce) Init ¶ added in v0.0.56
func (inst *DefaultSerivce) Init() error
func (*DefaultSerivce) RegisterHandler ¶ added in v0.0.56
func (inst *DefaultSerivce) RegisterHandler(name string, h Handler) error
type Filter ¶ added in v0.0.56
type Filter interface {
Init(service Service) error
Handle(ctx *TaskContext, next FilterChain) error
}
Filter 用来过滤请求
type FilterChain ¶ added in v0.0.56
type FilterChain interface {
Handle(ctx *TaskContext) error
}
FilterChain 代表过滤器链条
type FilterChainBuilder ¶ added in v0.0.56
type FilterChainBuilder struct {
// contains filtered or unexported fields
}
func (*FilterChainBuilder) Add ¶ added in v0.0.56
func (inst *FilterChainBuilder) Add(priority int, filter Filter)
func (*FilterChainBuilder) Create ¶ added in v0.0.56
func (inst *FilterChainBuilder) Create(reverse bool) FilterChain
func (*FilterChainBuilder) Len ¶ added in v0.0.56
func (inst *FilterChainBuilder) Len() int
func (*FilterChainBuilder) Less ¶ added in v0.0.56
func (inst *FilterChainBuilder) Less(a, b int) bool
func (*FilterChainBuilder) Swap ¶ added in v0.0.56
func (inst *FilterChainBuilder) Swap(a, b int)
type Handler ¶
type Handler interface {
Init(service Service) error
Handle(ctx *TaskContext) error
}
Handler 是某条具体命令的处理器
type Service ¶
type Service interface {
RegisterHandler(name string, h Handler) error
FindHandler(name string) (Handler, error)
GetHandlerNames() []string
// AddFilter 添加一个过滤器到服务中。
// priority 是过滤器的优先顺序,数值越大,优先级越高,处理顺序越靠前。
AddFilter(priority int, filter Filter) error
GetFilterChain() FilterChain
GetClient() Client
}
Service 是用来处理命令的服务
type TaskContext ¶ added in v0.0.56
type TaskContext struct {
Context lang.Context
CurrentTask *TaskUnit
Handler Handler
Service Service
TaskList []*TaskUnit
}
TaskContext 表示正在执行的任务
func (*TaskContext) Clone ¶ added in v0.0.56
func (inst *TaskContext) Clone() *TaskContext
Clone 生成 TaskContext 的副本(浅拷贝)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.