Documentation
¶
Overview ¶
Package commandBase 抽象的Command执行体结构,利用泛型提供多数据类型支持的Command解析、执行流程,约定Root节点为初始节点,不会参与执行匹配
@update 2024-07-18 05:25:13
Index ¶
- type Command
- func (c *Command[T]) AddArgs(args ...string) *Command[T]
- func (c *Command[T]) AddSubCommand(subCommand *Command[T]) *Command[T]
- func (c *Command[T]) AddUsage(usage string) *Command[T]
- func (c *Command[T]) BuildChain()
- func (c *Command[T]) CheckUsage(args ...string) (usage string, isHelp bool)
- func (c *Command[T]) Execute(ctx context.Context, data T, args []string) error
- func (c *Command[T]) FormatUsage() string
- func (c *Command[T]) GetSubCommands() []string
- func (c *Command[T]) GetSupportArgs() []string
- func (c *Command[T]) Validate(ctx context.Context, data T, args []string) bool
- type CommandFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command[T any] struct { Name string SubCommands map[string]*Command[T] Func CommandFunc[T] Usage string SupportArgs map[string]struct{} // contains filtered or unexported fields }
Command Repeat
@author heyuhengmatt @update 2024-07-18 04:43:37
func NewCommand ¶
func NewCommand[T any](name string, fn CommandFunc[T]) *Command[T]
NewCommand 创建一个新的Command结构
@param name string @param fn CommandFunc[T] @return *Command @author heyuhengmatt @update 2024-07-18 05:29:58
func NewRootCommand ¶
func NewRootCommand[T any](fn CommandFunc[T]) *Command[T]
NewCommand 创建一个新的Command结构
@param name string @param fn CommandFunc[T] @return *Command @author heyuhengmatt @update 2024-07-18 05:29:58
func (*Command[T]) AddSubCommand ¶
AddSubCommand 添加一个SubCommand
@param c *Command[T] @return AddSubCommand @author heyuhengmatt @update 2024-07-18 05:30:07
func (*Command[T]) BuildChain ¶
func (c *Command[T]) BuildChain()
BuildChain 从当前节点开始,执行Command
@param c *Command[T] @return Execute @author heyuhengmatt @update 2024-07-18 05:30:21
func (*Command[T]) Execute ¶
Execute 从当前节点开始,执行Command
@param c *Command[T] @return Execute @author heyuhengmatt @update 2024-07-18 05:30:21
func (*Command[T]) GetSubCommands ¶
GetSubCommands 获取当前节点的所有SubCommands
@param c @return GetSubCommands
func (*Command[T]) GetSupportArgs ¶
GetSupportArgs 获取当前节点的所有SubCommands
@param c @return GetSubCommands
Click to show internal directories.
Click to hide internal directories.