Skip to main content

systemprompt_cli/shared/
process.rs

1use anyhow::{anyhow, Context, Result};
2use std::path::PathBuf;
3use std::process::Command;
4
5pub fn run_command_in_dir(command: &str, args: &[&str], directory: &PathBuf) -> Result<()> {
6    let status = Command::new(command)
7        .args(args)
8        .current_dir(directory)
9        .status()
10        .with_context(|| format!("Failed to run: {} {}", command, args.join(" ")))?;
11
12    if !status.success() {
13        return Err(anyhow!("Command failed: {} {}", command, args.join(" ")));
14    }
15
16    Ok(())
17}