use crate::error::Result;
use std::process::{Command, Output};
pub fn execute_command(cmd: &str, args: &[&str]) -> Result<Output> {
let output = Command::new(cmd).args(args).output()?;
Ok(output)
}
pub fn is_command_available(cmd: &str) -> bool {
if Command::new(cmd)
.arg("--version")
.output()
.map(|o| o.status.success())
.unwrap_or(false)
{
return true;
}
if cfg!(windows) && !cmd.ends_with(".exe") {
let cmd_with_exe = format!("{}.exe", cmd);
return Command::new(&cmd_with_exe)
.arg("--version")
.output()
.map(|o| o.status.success())
.unwrap_or(false);
}
false
}