From 17d1fd85938b45a52450c80624a59b8e94ad29a7 Mon Sep 17 00:00:00 2001 From: James TD Smith Date: Wed, 8 Jul 2020 17:31:46 +0100 Subject: [PATCH] Add CLI options for highstate formatter modes Support the --state-output and --state-verbose options for the highstate formatter. These allow selecting a more compact output format for states without changes or errors or hiding them entirely. --- pepper/cli.py | 15 +++++++++++++++ pepper/script.py | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/pepper/cli.py b/pepper/cli.py index 68901d9..2048203 100644 --- a/pepper/cli.py +++ b/pepper/cli.py @@ -108,6 +108,21 @@ def parse(self): ''') ) + self.parser.add_option( + '--state-output', dest='state_output', default="full", type="choice", + choices = [ "full", "terse", "mixed", "changes", "filter" ], + help=textwrap.dedent(''' + Output mode for highstate formatter + ''') + ) + + self.parser.add_option( + '--state-verbose', dest='state_verbose', default=None, + help=textwrap.dedent(''' + Set to false to hide results with no changes + ''') + ) + 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..a261f19 100755 --- a/pepper/script.py +++ b/pepper/script.py @@ -36,6 +36,11 @@ def __init__(self): self.opts = {} if self.cli.options.output_file is not None: self.opts['output_file'] = self.cli.options.output_file + if self.cli.options.state_output is not None: + self.opts['state_output'] = self.cli.options.state_output + if self.cli.options.state_verbose is not None: + self.opts['state_verbose'] = self.cli.options.state_verbose in [ "true", "True", "1" ] + @property def output(self):