Reputation: 4133
For example:
let mut com = std::process::Command::new("ProgramA");
com.env("ENV_1", "VALUE_1")
.arg("-a")
.arg("foo")
.arg("-b")
.arg("--argument=bar");
// Get the command line string somehow here.
com.output().unwrap();
This will spawn a process with this command line "ProgramA" -a foo -b "--argument=with space"
associated with it.
Is there a way to get this back out from the com
object?
Upvotes: 4
Views: 2496
Reputation: 4133
It turns out Command
implements Debug
; this will give me the desired result:
let answer = format!("{:?}", com);
Upvotes: 3