All our subcommands are going to learn --json eventually, and they
shouldn't all have to do this individually.
The next commit uses this to automatically format CommandErrors as JSON.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
raw_argv = None
raw_args = None
raw_kwargs = None
+ preferred_output_format = None
def _set_files(self, outf=None, errf=None):
if outf is not None:
del kwargs[option.dest]
kwargs.update(optiongroups)
+ if kwargs.get('output_format') == 'json':
+ self.preferred_output_format = 'json'
+ else:
+ # we need to reset this for the tests that reuse the
+ # samba-tool object.
+ self.preferred_output_format = None
+
if self.use_colour:
self.apply_colour_choice(kwargs.pop('color', 'auto'))