Mercurial > piecrust2
changeset 579:42a5e78e782a
cli: Add `--no-color` option.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 30 Dec 2015 14:46:51 -0800 |
parents | 683be25cbdb2 |
children | c7ac7dc2fe73 |
files | piecrust/main.py |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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)