sharkdp / pastel

A command-line tool to generate, analyze, convert and manipulate colors
Apache License 2.0
5k stars 97 forks source link

Pastel paint doesn't work if stdout is not a terminal #73

Closed joerixaop closed 4 years ago

joerixaop commented 4 years ago

For a command which only goal is to add formatting to text it's unexpected to not get any formatting at all.

Even if this is intended behaviour I'd suggest adding a command line flag to force color to be always present.

sharkdp commented 4 years ago

Thank you for the feedback.

For a command which only goal is to add formatting to text it's unexpected to not get any formatting at all.

I am calling it a feature, not a bug :smile:. A lot of applications automatically deactivate their colored output when stdout is not a terminal. pastel paint does the same, such that the same behavior would be inherited by shell scripts that use pastel paint to write colored text to stdout.

Even if this is intended behaviour I'd suggest adding a command line flag to force color to be always present.

There is: Take a look at the -m/--color-mode flag that is present for every pastel command:

pastel --color-mode=24bit paint red "test" | cat    # this should print colored output

That being said, I agree that the ergonomics (and documentation!) around this can be improved. I'm very happy for any kind of suggestion.

For example: it might be a good idea to add something like --color-mode=force, which still auto-detects whether 8bit or 24bit ANSI sequences should be used.

see also: #48

sharkdp commented 4 years ago

Closing this for now, let me know if there are unanswered questions