Strategy command

This commit is contained in:
2026-07-31 00:56:16 +02:00
parent ccac73c3c5
commit e4ba12c5de
2 changed files with 21 additions and 5 deletions
+20 -3
View File
@@ -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(