syncable_cli/common/command_utils.rs
1use crate::error::Result;
2use std::process::{Command, Output};
3
4/// Execute a command safely and return the output
5pub fn execute_command(cmd: &str, args: &[&str]) -> Result<Output> {
6 let output = Command::new(cmd)
7 .args(args)
8 .output()?;
9
10 Ok(output)
11}
12
13/// Check if a command is available in PATH
14pub fn is_command_available(cmd: &str) -> bool {
15 Command::new(cmd)
16 .arg("--version")
17 .output()
18 .is_ok()
19}