From e2f164336dfe2ea663ba0bb20be1bdc586e04904 Mon Sep 17 00:00:00 2001 From: Marcos Bjoerkelund Date: Fri, 14 Jun 2024 13:56:00 +0200 Subject: [PATCH] osc results: Add support for --format for default text mode --- osc/commandline.py | 3 ++- osc/core.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 0bc7dc63..c91628ce 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -6055,7 +6055,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. @cmdln.option('', '--csv', action='store_true', default=False, help='generate output in CSV format') @cmdln.option('', '--format', default='%(repository)s|%(arch)s|%(state)s|%(dirty)s|%(code)s|%(details)s', - help='format string for csv output') + help='format string for default or csv output (not supported for xml)') @cmdln.option('--show-excluded', action='store_true', help='show repos that are excluded for this package') def do_results(self, subcmd, opts, *args): @@ -6129,6 +6129,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. kwargs['verbose'] = opts.verbose kwargs['wait'] = opts.watch kwargs['printJoin'] = '\n' + kwargs['format'] = opts.format get_results(**kwargs) # WARNING: this function is also called by do_results. You need to set a default there diff --git a/osc/core.py b/osc/core.py index 5dd96de5..bc4e5318 100644 --- a/osc/core.py +++ b/osc/core.py @@ -4101,8 +4101,13 @@ def get_results(apiurl: str, project: str, package: str, verbose=False, printJoi # hmm the function name is a bit too generic - something like # get_package_results_human would be better, but this would break the existing # api (unless we keep get_results around as well)... - result_line_templ = '%(rep)-20s %(arch)-10s %(status)s' - result_line_mb_templ = '%(rep)-20s %(arch)-10s %(pkg)-30s %(status)s' + format = kwargs.pop('format') + if format is None: + result_line_templ = '%(rep)-20s %(arch)-10s %(status)s' + result_line_mb_templ = '%(rep)-20s %(arch)-10s %(pkg)-30s %(status)s' + else: + result_line_templ = format + result_line_mb_templ = format r = [] printed = False multibuild_packages = kwargs.pop('multibuild_packages', [])