Respect NO_COLOR environment variable 3.1
authorSergey Matveev <stargrave@stargrave.org>
Wed, 14 Feb 2018 07:38:59 +0000 (10:38 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 14 Feb 2018 07:38:59 +0000 (10:38 +0300)
doc/news.rst
pyderasn.py

index 0363d7d8fe922360687be1269824f616939775b3..dd3a14328d62d28518eb521a402965af5f6697eb 100644 (file)
@@ -6,6 +6,7 @@ News
 3.1
 ---
 * Fix bug related to DecodeError showing with DecodePathDefBy entities
+* Respect ``NO_COLOR`` environment variable
 
 .. _release3.0:
 
index 3ed23da12c2fb486359224fc1275413b9da44980..386f234ae4b7adf62cd2ed446ab84f71c14ce57f 100755 (executable)
@@ -472,6 +472,7 @@ from collections import namedtuple
 from collections import OrderedDict
 from datetime import datetime
 from math import ceil
+from os import environ
 
 from six import add_metaclass
 from six import binary_type
@@ -4499,11 +4500,6 @@ def main():  # pragma: no cover
         "--defines-by-path",
         help="Python path to decoder's defines_by_path",
     )
-    parser.add_argument(
-        "--with-colours",
-        action='store_true',
-        help="Enable coloured output",
-    )
     parser.add_argument(
         "DERFile",
         type=argparse.FileType("rb"),
@@ -4530,7 +4526,7 @@ def main():  # pragma: no cover
     print(pprinter(
         obj,
         oids=oids,
-        with_colours=True if args.with_colours else False,
+        with_colours=True if environ.get("NO_COLOR") is None else False,
     ))
     if tail != b"":
         print("\nTrailing data: %s" % hexenc(tail))