From e4ba12c5de6894063e937d897ef91afc582574a7 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Fri, 31 Jul 2026 00:56:16 +0200 Subject: [PATCH] Strategy command --- pulse-sdk/src/lib.rs | 3 +-- src/engine/engine/command.rs | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pulse-sdk/src/lib.rs b/pulse-sdk/src/lib.rs index ee5fe3e..af0744e 100644 --- a/pulse-sdk/src/lib.rs +++ b/pulse-sdk/src/lib.rs @@ -8,15 +8,14 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt}; use crate::{general::LogKind, strategy::StrategyEngineMessage}; pub mod prelude { + pub use crate::Strategy; pub use crate::general::*; pub use crate::server_path; pub use crate::strategy::*; pub use crate::terminal::*; - pub use crate::Strategy; pub use hypersdk; pub use postcard; - pub use tokio; } pub fn server_path() -> std::path::PathBuf { diff --git a/src/engine/engine/command.rs b/src/engine/engine/command.rs index 577ab31..5cee75e 100644 --- a/src/engine/engine/command.rs +++ b/src/engine/engine/command.rs @@ -1,10 +1,14 @@ use crate::{engine::Engine, store::config::Config}; -use pulse_sdk::terminal::{ItemState, Mode, StrategyStatus}; +use pulse_sdk::prelude::*; use toml::Value; impl Engine { - pub async fn execute_command(&self, command: &str, args: Vec<&str>) -> tokio::io::Result<()> { + pub async fn execute_command( + &self, + command: &str, + mut args: Vec<&str>, + ) -> tokio::io::Result<()> { match command { "config" | "cfg" => { if args.len() == 0 { @@ -43,7 +47,7 @@ impl Engine { .await?; } - "strategy" | "strat" | "str" | "sg" => { + "strategy" | "strat" | "sg" => { set_cfg!(id, { let id: String = id; @@ -166,6 +170,19 @@ impl Engine { } } + "strategy" | "strat" | "sg" => { + let Some(strategy_command) = args.drain(0..=0).next() else { + return self.invalid_command_usage("strategy").await; + }; + + self.strategy_engine + .send(&StrategyEngineMessage::Command { + command: strategy_command.to_owned(), + args: args.into_iter().map(Into::into).collect(), + }) + .await?; + } + _ => { self.terminal_server .error(