wbailey / command_line_reporter

A gem for making it easy to produce a report while a ruby script is executing
Apache License 2.0
432 stars 23 forks source link

Don't print colors when not on a TTY #26

Open tas50 opened 8 years ago

tas50 commented 8 years ago

When piping to another command or to a file the colors shouldn't be printed. Otherwise the output when running commands in a cron job for example is pretty horrible. Here's a snippet of a command I run via cron:

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓ ┃ ^[[1m^[[34m Repo Name ^[[0m^[[0m ┃ ^[[1m^[[31mOpen PRs ^[[0m^[[0m ┃ ^[[1m^[[31mIssues ^[[0m^[[0m ┃ ^[[1m^[[31mOldest PR ^[[0m^[[0m ┃ ^[[1m^[[31mOldest Iss^[[0m^[[0m ┃

wbailey commented 8 years ago

Horrible is a strong word. Are you adding colors to the table and just asking for a way to run the report with them turned off regardless of the instructions in the code? By default it doesn't add colors/bold unless you tell it to.

tas50 commented 8 years ago

Horrible was probably a horrible ;) word choice. I am telling it to use color in the table, but ideally that would only be displayed in a shell. A lot of CLI tools that use coloring do this same thing to avoid printing the color codes when output is piped to redirected to a file.