From 49192dbb98e0ab1f2a66b4786fac86d63f69be64 Mon Sep 17 00:00:00 2001 From: "1992414357@qq.com" <1992414357@qq.com> Date: Mon, 9 Jun 2025 01:44:36 +0800 Subject: 重构所有部分 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/data/controller/cli/cli_command.rs | 48 +++++++++++++++++++++++++++++ core/src/data/controller/cli/mod.rs | 1 + 2 files changed, 49 insertions(+) create mode 100644 core/src/data/controller/cli/cli_command.rs create mode 100644 core/src/data/controller/cli/mod.rs (limited to 'core/src/data/controller/cli') diff --git a/core/src/data/controller/cli/cli_command.rs b/core/src/data/controller/cli/cli_command.rs new file mode 100644 index 0000000..b5c0414 --- /dev/null +++ b/core/src/data/controller/cli/cli_command.rs @@ -0,0 +1,48 @@ +use std::sync::{Arc, Mutex}; +use clap::{Parser, Subcommand}; +use nogamepads::entry_mutex; +use crate::data::controller::runtime::structs::ControllerRuntime; +use crate::data::message::enums::ControlMessage; +use crate::data::message::traits::MessageManager; +use crate::service::service_types::ServiceType::TCPConnection; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +pub struct ControllerCli { + #[command(subcommand)] + command: Commands, +} + +#[derive(Subcommand, Debug)] +enum Commands { + + #[command(about = "Clean the screen")] + Clear, + + #[command(about = "Send a message")] + Message, + + #[command(about = "Close the controller")] + Close +} + +pub fn process_controller_cli(runtime: Arc>, cmd: ControllerCli) { + + match cmd.command { + Commands::Clear => { + + } + + Commands::Message => { + entry_mutex!(runtime, |guard| { + guard.send(ControlMessage::Msg("fuck".to_string()), 0, TCPConnection); + }); + } + + Commands::Close => { + entry_mutex!(runtime, |guard| { + guard.close(); + }); + } + } +} \ No newline at end of file diff --git a/core/src/data/controller/cli/mod.rs b/core/src/data/controller/cli/mod.rs new file mode 100644 index 0000000..043f7b8 --- /dev/null +++ b/core/src/data/controller/cli/mod.rs @@ -0,0 +1 @@ +pub mod cli_command; \ No newline at end of file -- cgit