# HG changeset patch # User Ludovic Chabant # Date 1451515611 28800 # Node ID 42a5e78e782a4a39a36e34e4413b74c554845360 # Parent 683be25cbdb2d90b50fb4cc1fbe0ae851d549a49 cli: Add `--no-color` option. diff -r 683be25cbdb2 -r 42a5e78e782a piecrust/main.py --- a/piecrust/main.py Wed Dec 30 14:46:34 2015 -0800 +++ b/piecrust/main.py Wed Dec 30 14:46:51 2015 -0800 @@ -86,6 +86,7 @@ self.config_variant = config_variant self.config_values = [] self.debug_only = [] + self.no_color = False def _parse_config_value(arg): @@ -135,6 +136,8 @@ res.debug = True elif arg == '--quiet': res.quiet = True + elif arg == '--no-color': + res.no_color = True else: break @@ -144,7 +147,11 @@ if res.debug and res.quiet: raise Exception("You can't specify both --debug and --quiet.") - colorama.init() + strip_colors = None + if res.no_color: + strip_colors = True + + colorama.init(strip=strip_colors) root_logger = logging.getLogger() root_logger.setLevel(logging.INFO) if res.debug or res.log_debug: @@ -243,6 +250,10 @@ '--log-debug', help="Log debug messages to the log file.", action='store_true') + parser.add_argument( + '--no-color', + help="Don't use colorized output.", + action='store_true') commands = sorted(app.plugin_loader.getCommands(), key=lambda c: c.name)