Strategy command
This commit is contained in:
@@ -8,15 +8,14 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
|||||||
use crate::{general::LogKind, strategy::StrategyEngineMessage};
|
use crate::{general::LogKind, strategy::StrategyEngineMessage};
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
|
pub use crate::Strategy;
|
||||||
pub use crate::general::*;
|
pub use crate::general::*;
|
||||||
pub use crate::server_path;
|
pub use crate::server_path;
|
||||||
pub use crate::strategy::*;
|
pub use crate::strategy::*;
|
||||||
pub use crate::terminal::*;
|
pub use crate::terminal::*;
|
||||||
pub use crate::Strategy;
|
|
||||||
|
|
||||||
pub use hypersdk;
|
pub use hypersdk;
|
||||||
pub use postcard;
|
pub use postcard;
|
||||||
pub use tokio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn server_path() -> std::path::PathBuf {
|
pub fn server_path() -> std::path::PathBuf {
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
use crate::{engine::Engine, store::config::Config};
|
use crate::{engine::Engine, store::config::Config};
|
||||||
|
|
||||||
use pulse_sdk::terminal::{ItemState, Mode, StrategyStatus};
|
use pulse_sdk::prelude::*;
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
|
|
||||||
impl Engine {
|
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 {
|
match command {
|
||||||
"config" | "cfg" => {
|
"config" | "cfg" => {
|
||||||
if args.len() == 0 {
|
if args.len() == 0 {
|
||||||
@@ -43,7 +47,7 @@ impl Engine {
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
"strategy" | "strat" | "str" | "sg" => {
|
"strategy" | "strat" | "sg" => {
|
||||||
set_cfg!(id, {
|
set_cfg!(id, {
|
||||||
let id: String = 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
|
self.terminal_server
|
||||||
.error(
|
.error(
|
||||||
|
|||||||
Reference in New Issue
Block a user