[lkml]   [2016]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: add --no-color option
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 <>
> Acked-by: Valentin Rothberg <>

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

- Josh Triplett

 \ /
  Last update: 2016-07-04 14:41    [W:0.058 / U:4.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site