From 54876436a23f14951f2e6353e9072c9a098b35b4 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 14 Feb 2018 10:38:59 +0300 Subject: [PATCH 1/1] Respect NO_COLOR environment variable --- doc/news.rst | 1 + pyderasn.py | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/doc/news.rst b/doc/news.rst index 0363d7d..dd3a143 100644 --- a/doc/news.rst +++ b/doc/news.rst @@ -6,6 +6,7 @@ News 3.1 --- * Fix bug related to DecodeError showing with DecodePathDefBy entities +* Respect ``NO_COLOR`` environment variable .. _release3.0: diff --git a/pyderasn.py b/pyderasn.py index 3ed23da..386f234 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -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)) -- 2.44.0