added --color flag to force color even if stdout is a tty
This commit is contained in:
parent
1c5abb8419
commit
b92012dae6
|
@ -164,6 +164,11 @@ common_args = [
|
|||
"action": 'store_true',
|
||||
"default": False,
|
||||
}),
|
||||
(["--color"], {
|
||||
"help": "always use ANSI colors in output",
|
||||
"action": 'store_true',
|
||||
"default": False,
|
||||
}),
|
||||
(["--quiet"], {
|
||||
"help": "don't write to stdout on success",
|
||||
"action": 'store_true',
|
||||
|
|
|
@ -110,6 +110,11 @@ def use_ansi_color():
|
|||
if sys.platform == 'win32' and 'ANSICON' not in os.environ:
|
||||
return False
|
||||
|
||||
# With the --color flag, force color, even if stdout is a tty
|
||||
# and even if --no-color is also specified (!)
|
||||
if "--color" in sys.argv:
|
||||
return True
|
||||
|
||||
# Don't show color if stdout is not a tty, e.g. if output is piped on
|
||||
if not sys.stdout.isatty():
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue