You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my project, I build up a command to run dynamically. For instance, I have a test where I check that it is possible to specify the input on the command line or via stdin. It looks something like this:
for stdin in [false, true] {
let mut cmd = Command::cargo_bin("sq")?;
cmd.args(&["revoke",
"certificate",
"compromised", "oh no!"]);
if let Some(dir) = tmp_dir.as_ref() {
let alice_pgp = dir.path().join("alice.pgp");
let mut file = File::create(&alice_pgp)?;
file.write_all(&alice_tsk)?;
cmd.args(&["--certificate", &*alice_pgp.to_string_lossy()]);
} else {
cmd.write_stdin(alice_tsk);
}
}
I wanted to print out what is going to be run, so I added: eprintln!("Running: {:?}", cmd);. That prints:
In the case where I feed the data via stdin, that is very noisy. (I would have been happy to just print the command, but cmd is private and I didn't find a getter. Perhaps it makes sense to add one.) I think it would be better to do something like the following:
If stdin is, say, only printable ascii characters print it as such
Otherwise, print it as nicely formatted hex similar to xxd:
In my project, I build up a command to run dynamically. For instance, I have a test where I check that it is possible to specify the input on the command line or via stdin. It looks something like this:
I wanted to print out what is going to be run, so I added:
eprintln!("Running: {:?}", cmd);
. That prints:In the case where I feed the data via
stdin
, that is very noisy. (I would have been happy to just print the command, butcmd
is private and I didn't find a getter. Perhaps it makes sense to add one.) I think it would be better to do something like the following:stdin
is, say, only printable ascii characters print it as suchxxd
:Thanks for the great project!
The text was updated successfully, but these errors were encountered: