use std::collections::HashMap;
use std::path::PathBuf;
use std::time::Duration;
use tokio_util::sync::CancellationToken;
use crate::value::Value;
#[derive(Default, Clone)]
pub struct ExecuteOptions {
pub vars: HashMap<String, Value>,
pub timeout: Option<Duration>,
pub cancel_token: Option<CancellationToken>,
pub cwd: Option<PathBuf>,
}
impl ExecuteOptions {
pub fn new() -> Self {
Self::default()
}
pub fn with_vars(mut self, vars: HashMap<String, Value>) -> Self {
self.vars = vars;
self
}
pub fn with_var(mut self, name: impl Into<String>, value: Value) -> Self {
self.vars.insert(name.into(), value);
self
}
pub fn with_timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(timeout);
self
}
pub fn with_cancel_token(mut self, token: CancellationToken) -> Self {
self.cancel_token = Some(token);
self
}
pub fn with_cwd(mut self, cwd: PathBuf) -> Self {
self.cwd = Some(cwd);
self
}
}