-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels