diff --git a/osc/cmdln.py b/osc/cmdln.py index e3fafd7b..069677b4 100644 --- a/osc/cmdln.py +++ b/osc/cmdln.py @@ -6,6 +6,7 @@ A modern, lightweight alternative to cmdln.py from https://github.com/trentm/cmd import argparse import inspect import sys +import textwrap def option(*args, **kwargs): @@ -78,6 +79,19 @@ def hide(value=True): class HelpFormatter(argparse.RawDescriptionHelpFormatter): + def _split_lines(self, text, width): + # remove the leading and trailing whitespaces to avoid printing unwanted blank lines + text = text.strip() + + result = [] + for line in text.splitlines(): + if not line.strip(): + # textwrap normally returns [] on a string that contains only whitespaces; we want [""] to print a blank line + result.append("") + else: + result.extend(textwrap.wrap(line, width)) + return result + def _format_action(self, action): if isinstance(action, argparse._SubParsersAction): parts = [] diff --git a/osc/commandline.py b/osc/commandline.py index 9a7923a6..10113b3c 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -7172,7 +7172,14 @@ Please submit there instead, or use --nodevelproject to force direct submission. @cmdln.option('--build-opt', metavar='OPT', action='append', help='pass option OPT to the build command') @cmdln.option('--buildtool-opt', metavar='OPT', action='append', - help='pass option OPT to the build tool command (rpmbuild)') + help=textwrap.dedent( + """ + pass option OPT to the build tool command (rpmbuild), for example: + * don't clean build environment after a successful build: + --buildtool-opt=--noclean + """ + ), + ) @cmdln.option('--userootforbuild', '--login-as-root', action='store_true', help='Run build or shell as root. The default is to build as ' 'unprivileged user. Note that a line "# norootforbuild" '