use std::path::Path;
use std::process::Command;
pub(super) fn binary() -> Option<String> {
let candidate =
std::env::var("TETHERSCRIPT_BIN").unwrap_or_else(|_| "tetherscript".to_string());
Command::new(&candidate)
.arg("--help")
.output()
.ok()
.filter(|output| output.status.success())
.map(|_| candidate)
}
pub(super) fn run(binary: &str, subcommand: &str, path: &Path, directory: &Path) -> (bool, String) {
let output = Command::new(binary)
.arg(subcommand)
.arg(path)
.current_dir(directory)
.output()
.expect("tetherscript should run");
let combined = format!(
"{}{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
(output.status.success(), combined)
}