use super::{input_translate, output_translate};
use crate::{
cin_implements::common::{generate_command_vm, CommandGeneratorNodeJS},
runtimes::{CommandGenerator, CommandVmRuntime},
};
use anyhow::Result;
use nar_dev_utils::pipe;
use navm::vm::VmLauncher;
use std::path::PathBuf;
const COMMAND_ARGS_CXIN_NARS: [&str; 1] = ["shell"];
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct CXinJS {
command_generator: CommandGeneratorNodeJS,
}
impl CXinJS {
pub fn new(js_path: impl Into<PathBuf>) -> Self {
Self {
command_generator: CommandGeneratorNodeJS::new(js_path, COMMAND_ARGS_CXIN_NARS),
}
}
}
impl VmLauncher for CXinJS {
type Runtime = CommandVmRuntime;
fn launch(self) -> Result<CommandVmRuntime> {
pipe! {
self.command_generator
=> .generate_command()
=> generate_command_vm(_, (input_translate, output_translate))
=> .launch()
}
}
}