mre / prettyprint

Beautifully formatted output for your terminal 🌈
Apache License 2.0
200 stars 10 forks source link

Add support for stderr #9

Closed DrSensor closed 5 years ago

DrSensor commented 5 years ago

fix #8

Usage:

use prettyprint::*;

let pring = PrettyPrinter::default()
    .paging_mode(PagingMode::Error)
    .build()?;
mre commented 5 years ago

That's nice @DrSensor. Thanks!

I wonder if we should add a shorthand for that so that

let printer = PrettyPrinter::default()
    .stderr()
    .build()?;

does exactly the same as

let printer = PrettyPrinter::default()
    .paging_mode(PagingMode::Error)
    .build()?;

What do you think? If it's too tricky right now, we could also create an issue for it to add it later.

DrSensor commented 5 years ago

I first thought that too but then, what happens when someone configures it like this:

let printer = PrettyPrinter::default()
    .stderr()
    .paging_mode(PagingMode::Always)
    .build()?;

In my opinion, 👆 means that the pager will be outputted on stderr instead of stdout. However, the command less doesn't have a flag for that and I don't know how to pipe the pager output into stderr.

Let's make that as a separate issue 😃

mre commented 5 years ago

Fully agree. Merging. Thanks for the PR! ⭐️

mre commented 5 years ago

Published 0.6.0.