Files
sunhpc-rs/src/commands/server/mod.rs
2026-03-11 23:53:06 +08:00

33 lines
839 B
Rust

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),
}
}