run

Function run 

Source
pub fn run(
    program: &str,
    args: &[&str],
    dir: &Path,
    env: &[(&str, &str)],
) -> Result<()>
Expand description

Runs an external command, streaming its output to the terminal.

The command is printed before execution so CI logs show exactly what ran. A non-zero exit status is converted to an error.

§Arguments

  • program – The executable to run (looked up via PATH).
  • args – Arguments passed to the program.
  • dir – Working directory for the process.
  • env – Additional environment variables (key-value pairs).

§Errors

Returns an error if the process cannot be spawned or exits with a non-zero status code.

§Examples

use std::path::Path;
use xtask_lib::tasks::util::cmd::run;

// Run `cargo fmt --check` in the workspace root.
run("cargo", &["fmt", "--check"], Path::new("."), &[])?;