aboutsummaryrefslogtreecommitdiff
path: root/core/src/data/controller/cli
diff options
context:
space:
mode:
author1992414357@qq.com <1992414357@qq.com>2025-06-09 01:44:36 +0800
committer1992414357@qq.com <1992414357@qq.com>2025-06-09 01:44:36 +0800
commit49192dbb98e0ab1f2a66b4786fac86d63f69be64 (patch)
tree7cdf27c7cab5fb6b1aabc2ac7c44b7b492558945 /core/src/data/controller/cli
parentc9dbba0d288becb7f05cebe526be25c76e5a850a (diff)
重构所有部分
Diffstat (limited to 'core/src/data/controller/cli')
-rw-r--r--core/src/data/controller/cli/cli_command.rs48
-rw-r--r--core/src/data/controller/cli/mod.rs1
2 files changed, 49 insertions, 0 deletions
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<Mutex<ControllerRuntime>>, 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