macro_rules! cmd {
($cmd:expr $(, $(@$cmdargs:expr,)* $cmdarg:expr)* $(; $($k:ident = $v:tt),*)?) => { ... };
}Expand description
Create a new Cmd instance.
This is a simple wrapper over the std::process::Command and Cmd API. It
expects at least one argument for the program to run. Every comma seperated argument
thereafter is added to the command’s arguments. Arguments after an @-sign specify
collections of arguments (specifically impl IntoIterator<Item = impl AsRef<OsStr>).
The opional key=value arguments after a semicolon are simply translated to calling
the Cmd::<key> method with value as its arguments.
Note:
@-arguments must be followed by at least one normal argument. For example
cmd!("cmd", @args) will not compile but cmd!("cmd", @args, "other") will. You can
use key=value arguments to work around this limitation: cmd!("cmd"; args=(args)).
§Examples
let args_list = ["--foo", "--bar", "value"];
let mut cmd = cmd!("git", @args_list, "clone"; arg=("url.com"), env=("var", "value"));