Skip to main content

Crate puniyu_command

Crate puniyu_command 

Source
Expand description

§puniyu_command

统一的 puniyu 命令库,覆盖命令定义、元信息与注册表管理场景。

§特性

  • 提供 Command trait 定义命令行为
  • 提供 CommandRegistry 管理命令注册与查询
  • 复用 puniyu_command_types 中的参数、权限和动作类型
  • 支持命令别名、优先级和权限控制

§示例

use async_trait::async_trait;
use puniyu_command::{Arg, Command, CommandAction, Permission};
use puniyu_context::MessageContext;

struct HelloCommand;

#[async_trait]
impl Command for HelloCommand {
    fn name(&self) -> &'static str {
        "hello"
    }

    fn args(&self) -> Vec<Arg> {
        vec![Arg::string("name").required()]
    }

    fn permission(&self) -> Permission {
        Permission::All
    }

    async fn execute(&self, _ctx: &MessageContext) -> puniyu_error::Result<CommandAction> {
        CommandAction::done()
    }
}

Structs§

Arg
命令参数定义。
CommandInfo
命令信息

Enums§

ArgMode
命令参数匹配模式。
ArgType
命令参数数据类型。
ArgValue
命令参数值。
CommandAction
命令执行动作。
CommandId
命令标识符。
Permission
命令权限级别。

Traits§

Command
命令行为接口。