From 12c17279f8b1ed847ff8c9600f14394d22c63e75 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Wed, 15 Jul 2026 22:35:32 +0200 Subject: [PATCH] Working command system --- src/command.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/command.rs diff --git a/src/command.rs b/src/command.rs new file mode 100644 index 0000000..29ce0a3 --- /dev/null +++ b/src/command.rs @@ -0,0 +1,29 @@ +use crate::{PulseTradeApp, types::EventLog}; + +impl PulseTradeApp { + pub async fn execute_command(&mut self, ctx: &pulse_ui::state::Context, command: &str) { + if command.is_empty() { + return; + } + + let (command, args) = if let Some((command, args)) = command.split_once(" ") { + (command, args.split(" ").collect()) + } else { + (command, Vec::new()) + }; + + match command { + "exit" | "quit" | "leave" => { + ctx.close().await; + } + + _ => { + self.logs.lock().await.push(EventLog { + kind: crate::types::LogKind::ERR, + name: "cmd", + message: format!("Command '{}' not found", command), + }); + } + } + } +}