use std::{
fs,
path::Path,
process::{Child, Command, Stdio},
};
use super::Host;
#[derive(argh::FromArgs)]
#[argh(subcommand, name = "native")]
pub struct NativeArgs {}
impl NativeArgs {
pub fn start(self) -> Native {
Native {}
}
}
pub struct Native {}
impl Host for Native {
type Error = anyhow::Error;
fn read_file(&self, path: &Path) -> Result<Vec<u8>, anyhow::Error> {
Ok(fs::read(path)?)
}
fn launch(&self, program: String, args: Vec<String>) -> Result<Child, Self::Error> {
let child = Command::new(&program)
.args(args)
.stdin(Stdio::null()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn()?;
Ok(child)
}
}