Skip to content

Commit

Permalink
Merge pull request #1544 from dmach/build-noclean
Browse files Browse the repository at this point in the history
Document '--buildtool-opt=--noclean' example in 'build' command's help
  • Loading branch information
dmach authored Apr 22, 2024
2 parents d4ec8e7 + 9365a42 commit b4aa767
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 14 additions & 0 deletions osc/cmdln.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import argparse
import inspect
import sys
import textwrap


def option(*args, **kwargs):
Expand Down Expand Up @@ -78,6 +79,19 @@ def decorate(f):


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 = []
Expand Down
9 changes: 8 additions & 1 deletion osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7172,7 +7172,14 @@ def parse_repoarchdescr(self, args, noinit=False, alternative_project=None, igno
@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" '
Expand Down

0 comments on commit b4aa767

Please sign in to comment.