use crate::runtimes::{CommandVm, IoTranslators};
use nar_dev_utils::manipulate;
use std::{ffi::OsStr, path::Path, process::Command};
pub fn generate_command<S>(
exe_path: impl AsRef<Path>,
current_dir: Option<impl AsRef<Path>>,
args: impl IntoIterator<Item = S>,
) -> Command
where
S: AsRef<OsStr>,
{
let mut command = Command::new(exe_path.as_ref());
if let Some(current_dir) = current_dir {
command.current_dir(current_dir);
}
command.args(args);
command
}
pub fn generate_command_vm(command: Command, translators: impl Into<IoTranslators>) -> CommandVm {
manipulate!(
CommandVm::from(command)
=> .translators(translators)
)
}