1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/// Runs a system command and exits with code 1 if an error occurs.
///
/// # Arguments
///
/// * `$cmd` - The command to run in the current working directory. 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.
///
/// # Example
///
/// ```
/// use easy_cmd::run_command;
///
/// // Run a command in the current working directory.
/// run_command!("git status");
///
/// // The command can also be provided as a collection of strings.
/// run_command!(&["git", "status"]);
/// ```
/// 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"));
/// ```