2026-03-31 17:29:08 -04:00
|
|
|
use anyhow::Result;
|
|
|
|
|
use which::which;
|
|
|
|
|
|
|
|
|
|
pub struct Prereq {
|
|
|
|
|
pub cmd: &'static str,
|
|
|
|
|
pub install_hint: &'static str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const PREREQS: &[Prereq] = &[
|
2026-04-01 20:58:09 -04:00
|
|
|
Prereq {
|
|
|
|
|
cmd: "nu",
|
|
|
|
|
install_hint: "brew install nushell OR nix-env -iA nixpkgs.nushell",
|
|
|
|
|
},
|
|
|
|
|
Prereq {
|
|
|
|
|
cmd: "sops",
|
|
|
|
|
install_hint: "brew install sops OR nix-env -iA nixpkgs.sops",
|
|
|
|
|
},
|
|
|
|
|
Prereq {
|
|
|
|
|
cmd: "age",
|
|
|
|
|
install_hint: "brew install age OR nix-env -iA nixpkgs.age",
|
|
|
|
|
},
|
2026-03-31 17:29:08 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
pub fn check_prerequisites() -> Result<()> {
|
|
|
|
|
let missing: Vec<&Prereq> = PREREQS.iter().filter(|p| which(p.cmd).is_err()).collect();
|
|
|
|
|
if missing.is_empty() {
|
|
|
|
|
return Ok(());
|
|
|
|
|
}
|
|
|
|
|
eprintln!("Missing required tools:\n");
|
|
|
|
|
for p in &missing {
|
|
|
|
|
eprintln!(" {} — {}", p.cmd, p.install_hint);
|
|
|
|
|
}
|
|
|
|
|
anyhow::bail!("{} prerequisite(s) missing", missing.len())
|
|
|
|
|
}
|