Add --no-color argument
authorAntoine Busque <abusque@efficios.com>
Wed, 27 Apr 2016 19:10:15 +0000 (15:10 -0400)
committerAntoine Busque <abusque@efficios.com>
Wed, 27 Apr 2016 19:11:37 +0000 (15:11 -0400)
Signed-off-by: Antoine Busque <abusque@efficios.com>
lttnganalyses/cli/command.py

index d2a7be374f70cf8361838b7d39d1e392418ef87f..4facae653d355740cb93364b048f1e792619c804 100644 (file)
@@ -92,12 +92,13 @@ class Command:
         print(json.dumps(mi.get_error(msg, code)))
 
     def _non_mi_error(self, msg):
-        try:
-            import termcolor
+        if self._args.color:
+            try:
+                import termcolor
 
-            msg = termcolor.colored(msg, 'red', attrs=['bold'])
-        except ImportError:
-            pass
+                msg = termcolor.colored(msg, 'red', attrs=['bold'])
+            except ImportError:
+                pass
 
         print(msg, file=sys.stderr)
 
@@ -475,6 +476,8 @@ class Command:
         ap.add_argument('--debug', action='store_true',
                         help='Enable debug mode (or set {} environment variable)'.format(
                             self._DEBUG_ENV_VAR))
+        ap.add_argument('--no-color', action='store_false', dest='color',
+                        help='Disable colored output')
 
         # MI mode-dependent arguments
         if self._mi_mode:
This page took 0.024536 seconds and 5 git commands to generate.