From 58a859dbde947124612c4bf0ac2c1697053ab885 Mon Sep 17 00:00:00 2001 From: Chuigda Date: Tue, 27 Feb 2024 09:58:20 +0800 Subject: [PATCH] support engine startup args --- src/uciengine.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/uciengine.rs b/src/uciengine.rs index 2dde4ab..86ad9f4 100644 --- a/src/uciengine.rs +++ b/src/uciengine.rs @@ -3,6 +3,7 @@ use log::{debug, error, info, log_enabled, Level}; use envor::envor::env_true; use std::collections::HashMap; +use std::fmt::Display; use std::process::Stdio; use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; use tokio::process::Command; @@ -295,16 +296,21 @@ pub struct UciEngine { /// uci engine implementation impl UciEngine { + pub fn new(path: impl Display) -> std::sync::Arc { + Self::new_with_args(path, &[] as &[&str]) + } + /// create new uci engine - pub fn new(path: T) -> std::sync::Arc + pub fn new_with_args(path: T, args: &[impl ToString]) -> std::sync::Arc where - T: core::fmt::Display, + T: core::fmt::Display { // you can use anything that can be converted to string as path let path = path.to_string(); // spawn engine process let mut child = Command::new(path.as_str()) + .args(args.iter().map(|s| s.to_string())) .stdout(Stdio::piped()) .stdin(Stdio::piped()) .spawn()