stdout/stderr for text processes is ugly
This is partially my failure in #103. As we concentrated in that PR on binary data (which is my other use case), but not on default text output. So instead of printing the text nicely for more common case we print it with escaped \n, so if the output if not one-liner (i.e. some log) it's hard to read.
I see one of two possible approaches:
- Format as binary, but line-by line. So weird characters are visible as escapes, but multi-line text output is readable
- Detect whether the output is binary or not, (by trying from_utf8 first?). And then print text normally.
What do you think?
I'm in favor of
Format as binary, but line-by line. So weird characters are visible as escapes, but multi-line text output is readable
Format as binary, but line-by line. So weird characters are visible as escapes, but multi-line text output is readable
Is the idea that a linebreak would be added after each \n?
E.g., something like this:
stderr=```<9910 bytes total>" Blocking waiting for file lock on package cache\n Checking libc v0.2.138\n Checking cfg-if v1.0.0\n ....
Would instead look like this?
stderr=```<9910 bytes total>" Blocking waiting for file lock on package cache\n
Checking libc v0.2.138\n
Checking cfg-if v1.0.0\n
....
@tailhook Are you working on this, by chance?
No I'm not working on it.
You don't need \n unescaped linebreak works fine. (if you past your example into a Rust without editing you'll get two linebreaks, which is inconvenient)
I have a prototype working, but admittedly the boundaries between stdout, stderr, etc. become hard to find when the number of lines is large.
I can see at least six options.
- Do nothing and live with the current "ugly" output.
- Break lines unconditionally and live with the boundaries being hard to find.
- Indent. However, like @tailhook aluded to above, this would cause a disparity between the actual text and the text displayed.
- Add a method to
Assertto enable this option. However, this could make for a confusing API. E.g., something like the following could cause a user to thinkwith_linebreaksaffects the predicate instdout:Command::new(...) .assert() .with_linebreaks() .stdout(...); - Enable this functionality with a feature.
- Choose a reasonable limit (similar to
MIN_OVERFLOW, etc.) and show only a subset of the lines when the total number of lines would exceed that limit.
Thoughts?