From e0a85d873bd4f2e71d316663053a310a1948a61d Mon Sep 17 00:00:00 2001 From: Steven Daniele Date: Fri, 12 Apr 2024 09:08:51 -0400 Subject: [PATCH] Add force color option for Salt outputters The salt CLI commands offer an option to force color output. An option on the Pepper CLI now offers the equivalent feature. --- pepper/cli.py | 7 +++++++ pepper/script.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/pepper/cli.py b/pepper/cli.py index 68901d9..5979e28 100644 --- a/pepper/cli.py +++ b/pepper/cli.py @@ -108,6 +108,13 @@ def parse(self): ''') ) + self.parser.add_option( + '--output-force-color', dest='output_force_color', default=False, action='store_true', + help=textwrap.dedent(''' + Force salt outputter to use color when printing. + ''') + ) + self.parser.add_option( '--output-file', dest='output_file', default=None, help=textwrap.dedent(''' diff --git a/pepper/script.py b/pepper/script.py index 21afe63..61e304c 100755 --- a/pepper/script.py +++ b/pepper/script.py @@ -32,6 +32,8 @@ def __init__(self): self.cli = PepperCli() if HAS_SALT: self.opts = salt.config.client_config(self.cli.options.master) + if self.cli.options.output_force_color: + self.opts['color'] = True else: self.opts = {} if self.cli.options.output_file is not None: