diff options
| author | 1992414357@qq.com <1992414357@qq.com> | 2025-06-09 10:28:16 +0800 |
|---|---|---|
| committer | 1992414357@qq.com <1992414357@qq.com> | 2025-06-09 10:28:16 +0800 |
| commit | 7093b08b8efd6e35a434b2923c40b763b51e675b (patch) | |
| tree | fe46f65e50effe5a89055febd9af4c8d456241e1 /core/src/data/game | |
| parent | a75ee4f12e78b880f6d008a5e72d70b0c7f997b4 (diff) | |
将控制台的关闭改为了自动
Diffstat (limited to 'core/src/data/game')
| -rw-r--r-- | core/src/data/game/cli/cli_command.rs | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/core/src/data/game/cli/cli_command.rs b/core/src/data/game/cli/cli_command.rs index 9b74831..5f296f8 100644 --- a/core/src/data/game/cli/cli_command.rs +++ b/core/src/data/game/cli/cli_command.rs @@ -1,11 +1,9 @@ -use std::process::exit; use std::sync::{Arc, Mutex}; use clap::{Args, Parser, Subcommand}; use clearscreen::clear; use log::{info, warn}; use nogamepads::entry_mutex; use crate::data::game::runtime::structs::GameRuntime; -use crate::data::message::traits::MessageManager; use crate::data::player::structs::Player; #[derive(Parser, Debug)] @@ -28,9 +26,6 @@ enum Commands { #[command(about = "Close the game")] Close, - #[command(about = "Exit the console")] - Exit, - OnlineList, BannedList, @@ -67,33 +62,29 @@ struct SendMessageArgs { msg: String } -pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) { +pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) -> bool { match cmd.command { Commands::Clear => { clear().expect("Failed to clear screen"); - } Commands::LockGame => { entry_mutex!(runtime, |guard| { guard.lock_game(); - }) + }); } Commands::UnlockGame => { entry_mutex!(runtime, |guard| { guard.unlock_game(); - }) + }); } Commands::Close => { entry_mutex!(runtime, |guard| { guard.close_game(); - }) - } - - Commands::Exit => { - exit(1); + }); + return false; } Commands::OnlineList => { @@ -103,7 +94,7 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) { info!("{}.{}", i, account.id); i += 1; } - }) + }); } Commands::BannedList => { @@ -113,7 +104,7 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) { info!("{}.{}", i, account.id); i += 1; } - }) + }); } Commands::Ban(args) => { @@ -126,7 +117,7 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) { } else { warn!("Account number {} not found", args.index); } - }) + }); } Commands::Pardon(args) => { @@ -137,7 +128,7 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) { } else { warn!("Account number {} not found", args.index); } - }) + }); } Commands::Kick(args) => { @@ -150,7 +141,7 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) { } else { warn!("Account number {} not found", args.index); } - }) + }); } Commands::Event(args) => { @@ -163,7 +154,7 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) { } else { warn!("Account number {} not found", args.index); } - }) + }); } Commands::Message(args) => { @@ -176,7 +167,7 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) { } else { warn!("Account number {} not found", args.index); } - }) + }); } Commands::Pop => { @@ -186,7 +177,7 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) { } else { info!("None") } - }) + }); } Commands::PopAll => { @@ -194,7 +185,8 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) { while let Some((account, message)) = guard.pop_event() { info!("{}: {:?}", account.id, message); } - }) + }); } } + true }
\ No newline at end of file |
