Skip to content

Commit 4f59a29

Browse files
author
ocaisa
authored
Merge pull request #3151 from boegel/disable_help
mention --disable-* option in --help output for boolean options enabled by default
2 parents 0292c37 + 40ee0e8 commit 4f59a29

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

easybuild/base/generaloption.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,11 +1088,15 @@ def add_group_parser(self, opt_dict, description, prefix=None, otherdefaults=Non
10881088

10891089
if default is not None:
10901090
if len(str(default)) == 0:
1091-
extra_help.append("def ''") # empty string
1091+
extra_help.append("default: ''") # empty string
10921092
elif typ in ExtOption.TYPE_STRLIST:
1093-
extra_help.append("def %s" % sep.join(default))
1093+
extra_help.append("default: %s" % sep.join(default))
10941094
else:
1095-
extra_help.append("def %s" % default)
1095+
extra_help.append("default: %s" % default)
1096+
1097+
# for boolean options enabled by default, mention that they can be disabled using --disable-*
1098+
if default is True:
1099+
extra_help.append("disable with --disable-%s" % key)
10961100

10971101
if len(extra_help) > 0:
10981102
hlp += " (%s)" % ("; ".join(extra_help))

test/framework/options.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_help_long(self):
150150
topt = EasyBuildOptions(
151151
go_args=['-H'],
152152
go_nosystemexit=True, # when printing help, optparse ends with sys.exit
153-
go_columns=100, # fix col size for reproducible unittest output
153+
go_columns=200, # fix col size for reproducible unittest output
154154
help_to_string=True, # don't print to stdout, but to StingIO fh,
155155
prog='easybuildoptions_test', # generate as if called from generaloption.py
156156
)
@@ -165,6 +165,10 @@ def test_help_long(self):
165165
self.assertTrue(re.search("Regression test options", outtxt),
166166
"Not all option groups included in short help (2)")
167167

168+
# for boolean options, we mention in the help text how to disable them
169+
regex = re.compile("default: True; disable with --disable-cleanup-builddir", re.M)
170+
self.assertTrue(regex.search(outtxt), "Pattern '%s' found in: %s" % (regex.pattern, outtxt))
171+
168172
def test_no_args(self):
169173
"""Test using no arguments."""
170174

0 commit comments

Comments
 (0)