CommandExt
CommandExt
is a set of convenient extension traits for std::process::Command
which
make it easier to use, particularly in cargo scripts where many commands may be executed
with different requirements for error checking, logging, and so forth.
CommandExtCheck
CommandExtCheck
allows you to check the result of a command and get a nicely packaged
error containing printable output and error streams.
use Command;
use CommandExtCheck;
Usually, scripts probably will just use Command::new("cmd").args(["arg1", "arg2"]).check()?
.
CommandExtLog
CommandExtLog
allows you to add customizable logging to your commands.
use Command;
use ;
use Builder;
use ;
This logs:
[2023-12-13T21:04:17Z DEBUG command_ext::log] args: bash -c echo err >&2; echo ok
[2023-12-13T21:04:17Z INFO command_ext::log] status: exit status: 0
[2023-12-13T21:04:17Z TRACE command_ext::log] stdout: ok
[2023-12-13T21:04:17Z WARN command_ext::log] stderr: err
CommandExtTrace
CommandExtTrace
works very similarly to CommandExtLog
use ;
use stdout;
use Command;
use ;
use ;
This traces:
2023-12-13T21:06:31.739932Z DEBUG command_ext::trace: args: bash -c echo err >&2; echo ok
2023-12-13T21:06:31.741100Z INFO command_ext::trace: status: exit status: 0
2023-12-13T21:06:31.741138Z TRACE command_ext::trace: stdout: ok
2023-12-13T21:06:31.741147Z WARN command_ext::trace: stderr: err