I would love to enhance the existing functionality of CmdResult by a few points.
Use ExitStatus instead of code and success
We get the ExitStatus from the wait methods in UChild, so no extraction of code and success is required to initialize the CmdResult. On unix platforms we could provide a method in CmdResult to assert signals or whatever is available in std::os::unix::ExitStatusExt.
Rename stderr_is to stderr_trimmed_is and provide a stderr_is method which asserts the stderr untrimmed
This method gave a hard time once, until I found out that stderr is trimmed. The trimming should be more obvious.
Provide stdout_apply, stdout_str_apply, stderr_apply and stderr_str_apply methods which apply a function to the stdout (stderr) and return a CmdResult
Such method calls could for example look like
ucommand.run().stdout_str_apply(str::trim).stdout_only("hello world");
ucommand.run().stdout_apply(|s| &s[0..5]).stdout_only("hello");
This has the advantage, that we can stay in the CmdResult chain, instead of breaking out with let stdout = ucommand.run().stdout_str(), then doing something with stdout and then asserting this stdout manually.
I would love to enhance the existing functionality of
CmdResultby a few points.Use
ExitStatusinstead ofcodeandsuccessWe get the
ExitStatusfrom thewaitmethods inUChild, so no extraction ofcodeandsuccessis required to initialize theCmdResult. On unix platforms we could provide a method inCmdResultto assert signals or whatever is available instd::os::unix::ExitStatusExt.Rename
stderr_istostderr_trimmed_isand provide astderr_ismethod which asserts the stderr untrimmedThis method gave a hard time once, until I found out that stderr is trimmed. The trimming should be more obvious.
Provide
stdout_apply,stdout_str_apply,stderr_applyandstderr_str_applymethods which apply a function to the stdout (stderr) and return aCmdResultSuch method calls could for example look like
This has the advantage, that we can stay in the
CmdResultchain, instead of breaking out withlet stdout = ucommand.run().stdout_str(), then doing something withstdoutand then asserting thisstdoutmanually.