命令框架模块构建完成

This commit is contained in:
root
2026-03-11 23:43:24 +08:00
committed by Qichao.Sun
parent 8166e98cc7
commit 8b279df333
15 changed files with 472 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
use clap::Subcommand;
use anyhow::Result;
// 引入具体的命令逻辑文件
mod start;
mod stop;
// 引入新的 config 模块
pub mod config;
/// Server 子命令集的具体命令
#[derive(Subcommand)]
pub enum ServerCommands {
/// 启动服务器
Start(start::StartArgs),
/// 停止服务器
Stop(stop::StopArgs),
/// 服务器配置管理(三级命令入口)
#[command(subcommand)]
Config(config::ConfigCommands), // 引用 config 模块中的枚举
}
/// 执行 server 命令集的入口函数
pub fn execute(cmd: ServerCommands) -> Result<()> {
match cmd {
ServerCommands::Start(args) => start::run(args),
ServerCommands::Stop(args) => stop::run(args),
// 分发到 config 模块的 execute 函数
ServerCommands::Config(args) => config::execute(args),
}
}