use std::process::{Command, Stdio};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Requirement {
Binary(&'static str),
}
impl Requirement {
pub fn check(&self) -> bool {
match self {
Requirement::Binary(name) => Command::new(name)
.arg("--version")
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.is_ok(),
}
}
}
impl std::fmt::Display for Requirement {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Requirement::Binary(name) => write!(f, "`{name}` binary on PATH"),
}
}
}