Documentation ¶
Index ¶
- func SetupConsole(ctx context.Context, factory ConsoleFactory) error
- type AsyncClient
- type Client
- type ClientFactory
- type CommandHelpInfo
- type CommandHelper
- type Console
- type ConsoleFactory
- type Context
- type Filter
- type FilterChain
- type FilterChainBuilder
- type Handler
- type Service
- type Task
- type TaskContext
- type TaskListBuilder
- type TaskUnit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetupConsole ¶ added in v0.0.56
func SetupConsole(ctx context.Context, factory ConsoleFactory) error
SetupConsole 从上下文取控制台接口
Types ¶
type AsyncClient ¶ added in v0.0.57
type AsyncClient interface { GetContext() context.Context GetFactory() ClientFactory Execute(cmd string) task.Promise ExecuteTask(task *Task) task.Promise ExecuteScript(script string) task.Promise ExecuteWithArguments(cmd string, args []string) task.Promise }
AsyncClient 是用于执行命令的异步 API
type Client ¶
type Client interface { GetContext() context.Context GetFactory() ClientFactory Execute(cmd string) error ExecuteTask(task *Task) error ExecuteWithArguments(cmd string, args []string) error // execute multi-line commands ExecuteScript(script string) error }
Client 是用于执行命令的同步 API
type ClientFactory ¶ added in v0.0.57
type ClientFactory interface { CreateClient(ctx context.Context) Client CreateAsyncClient(ctx context.Context) AsyncClient }
ClientFactory 是命令客户端的工厂
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 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(ctx context.Context) Client GetClientFactory() ClientFactory }
Service 是用来处理命令的服务
type TaskContext ¶ added in v0.0.56
type TaskContext struct { Context context.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 的副本(浅拷贝)
type TaskListBuilder ¶ added in v0.0.57
type TaskListBuilder struct {
// contains filtered or unexported fields
}
func (*TaskListBuilder) AddLine ¶ added in v0.0.57
func (inst *TaskListBuilder) AddLine(line string, index int, args []string) error
func (*TaskListBuilder) Create ¶ added in v0.0.57
func (inst *TaskListBuilder) Create() []*TaskUnit
func (*TaskListBuilder) ParseScript ¶ added in v0.0.57
func (inst *TaskListBuilder) ParseScript(script string) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.