命令框架模块构建完成
This commit is contained in:
33
src/commands/server/mod.rs
Normal file
33
src/commands/server/mod.rs
Normal 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),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user