From c427e2e32625f05caa163de07480a92a47f27252 Mon Sep 17 00:00:00 2001 From: Scott Stevenson Date: Wed, 2 Jan 2019 18:32:24 +0000 Subject: [PATCH] Don't colour output if `NO_COLOR` is set This follows the informal standard defined at https://no-color.org, allowing users who don't want colour output from command line applications to set a single environment variable to disable it in all supported applications. --- docs/usage.rst | 3 ++- nox/__main__.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 1fe30cc7..07925619 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -184,7 +184,8 @@ Controlling color output By default, Nox will output colorful logs if you're using in an interactive terminal. However, if you are redirecting ``stderr`` to a file or otherwise -not using an interactive terminal, nox will output in plaintext. +not using an interactive terminal, or the environment variable ``NO_COLOR`` is +set, nox will output in plaintext. You can manually control Nox's output using the ``--nocolor`` and ``--forcecolor`` flags. diff --git a/nox/__main__.py b/nox/__main__.py index d56cc418..24fd8999 100644 --- a/nox/__main__.py +++ b/nox/__main__.py @@ -218,7 +218,7 @@ def main(): secondary.add_argument( "--nocolor", - default=not sys.stderr.isatty(), + default="NO_COLOR" in os.environ or not sys.stderr.isatty(), action="store_true", help="Disable all color output.", )