diff --git a/src/main.rs b/src/main.rs index f7d4c37..6ae348d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -124,6 +124,7 @@ async fn main() -> anyhow::Result<()> { match cli.runtime.to_lowercase().as_str() { "dummy" => run::(cli).await, + "automatic" => run::(cli).await, _ => { let err = anyhow::format_err!("Unsupported framework {}", cli.runtime); log::error!("{}", err); diff --git a/src/process.rs b/src/process.rs index 3ad45b5..f61030d 100644 --- a/src/process.rs +++ b/src/process.rs @@ -13,6 +13,7 @@ use std::task::Poll; use tokio::process::*; pub mod dummy; +pub mod automatic; pub mod win; #[derive(Default, Clone)] diff --git a/src/process/automatic.rs b/src/process/automatic.rs new file mode 100644 index 0000000..3eb2074 --- /dev/null +++ b/src/process/automatic.rs @@ -0,0 +1,33 @@ +use std::{path::Path, process::Stdio}; + +use tokio::process::Command; + +use super::{AiFramework, RuntimeArgs}; + +#[derive(Clone)] +pub struct Automatic { + +} + +static _STARTUP_SCRIPT: &str = "automatic/run.bat"; + +impl AiFramework for Automatic { + fn parse_args(args: &[String]) -> anyhow::Result { + RuntimeArgs::new(&_STARTUP_SCRIPT.into(), args) + } + + fn start(args: &super::RuntimeArgs) -> anyhow::Result { + log::info!("Start cmd"); + let exe = super::find_exe(_STARTUP_SCRIPT)?; + let mut cmd = Command::new(&exe); + let work_dir = exe.parent().unwrap(); + cmd.stdout(Stdio::piped()) + .stdin(Stdio::null()) + .current_dir(work_dir); + Ok(cmd.kill_on_drop(true).spawn()?) + } + + fn run(stdout: tokio::process::ChildStdout, report_fn: ReportFn) { + log::info!("Run cmd"); + } +}