diff --git a/core/colors.py b/core/colors.py index d4871580..b4c811d8 100644 --- a/core/colors.py +++ b/core/colors.py @@ -5,11 +5,18 @@ colors = True # Output should be colored machine = sys.platform # Detecting the os of current system checkplatform = platform.platform() # Get current version of OS -if machine.lower().startswith(('os', 'win', 'darwin', 'ios')): - colors = False # Colors shouldn't be displayed on mac & windows -if checkplatform.startswith("Windows-10") and int(platform.version().split(".")[2]) >= 10586: - colors = True - os.system('') # Enables the ANSI + +# Check for NO_COLOR environment variable, see https://no-color.org +if ('NO_COLOR' in os.environ) or ('--no-color' in sys.argv): + colors = False + +else : + if machine.lower().startswith(('os', 'win', 'darwin', 'ios')): + colors = False # Colors shouldn't be displayed on mac & windows + if checkplatform.startswith("Windows-10") and int(platform.version().split(".")[2]) >= 10586: + colors = True + os.system('') # Enables the ANSI + if not colors: end = red = white = green = yellow = run = bad = good = info = que = '' else: diff --git a/xsstrike.py b/xsstrike.py index 1aab695d..ebc77e8b 100644 --- a/xsstrike.py +++ b/xsstrike.py @@ -80,6 +80,8 @@ choices=core.log.log_config.keys(), default=None) parser.add_argument('--log-file', help='Name of the file to log', dest='log_file', default=core.log.log_file) +parser.add_argument('--no-color', help='disable colored output', dest='no_color', + action='store_true') args = parser.parse_args() # Pull all parameter values of dict from argparse namespace into local variables of name == key