On Mon, Jul 04, 2016 at 06:39:30PM +1000, Andrew Donnellan wrote:
> Add a new option, --no-color, to get rid of ANSI colour escape codes in the
> output. Useful if redirecting output to a file or piping to another script.
> 
> (It should really be --no-colour, but I'll accept US spelling in the name
> of consistency with existing usage in the code comments...)
> 
> Signed-off-by: Andrew Donnellan <andrew.donnel...@au1.ibm.com>
> Acked-by: Valentin Rothberg <valentinrothb...@gmail.com>

Rather than requiring an explicit option, how about detecting
whether stdout is a TTY and automatically suppressing color?
You could check "os.isatty(1)" in main(), and set a global "color =
False".  That would automatically handle the cases of redirecting to a
file or piping to another script, without requiring the user to pass
--no-color.

- Josh Triplett

Reply via email to