Macro embuild::cmd_spawn [−][src]
macro_rules! cmd_spawn {
($cmd : expr $(, $(@ $cmdargs : expr,) * $cmdarg : expr) *
$(; $($k : ident = $v : tt), *) ?) => { ... };
}Expand description
Spawn a command and return its handle.
This is a simple wrapper over the std::process::Command 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
std::process::Command::<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)).
After building the command std::process::Command::spawn is called and its return
value returned.
Examples
let args_list = ["--foo", "--bar", "value"];
cmd_spawn!("git", @args_list, "clone"; arg=("url.com"), env=("var", "value"));