run_command_in_dir

Macro run_command_in_dir 

Source
macro_rules! run_command_in_dir {
    ($cmd:expr, $dir:expr) => { ... };
}
Expand description

Runs a system command in a specific directory and exits with code 1 if an error occurs.

§Arguments

  • $cmd - The command to run in the directory specified by $dir. The command can be represented as a single string or a collection of strings, or as any other type that implements the crate::AsCommand trait.
  • $dir - Path to the directory that the command specified by $cmd should be run in (can be a &str, String, std::path::Path, or std::path::PathBuf.

§Example

use easy_cmd::run_command_in_dir;
use std::path::Path;

// Run a command in a specific directory.
run_command_in_dir!("git status", "src");

// The command can also be provided as a collection of strings, and the directory can also be
// specified as a Path.
run_command_in_dir!(&["git", "status"], Path::new("src"));