use anyhow::Result;
use std::process::Command;
use crate::config::ShimConfig;
#[cfg(unix)]
mod unix;
#[cfg(windows)]
mod windows;
pub struct PlatformExecutor {
#[cfg(windows)]
inner: windows::WindowsExecutor,
#[cfg(unix)]
inner: unix::UnixExecutor,
}
impl PlatformExecutor {
pub fn new() -> Self {
Self {
#[cfg(windows)]
inner: windows::WindowsExecutor::new(),
#[cfg(unix)]
inner: unix::UnixExecutor::new(),
}
}
pub fn execute(&self, command: Command, config: &ShimConfig) -> Result<i32> {
self.inner.execute(command, config)
}
}
impl Default for PlatformExecutor {
fn default() -> Self {
Self::new()
}
}
trait PlatformExecutorTrait {
fn execute(&self, command: Command, config: &ShimConfig) -> Result<i32>;
}