Repository: easybuilders/easybuild-framework

Issue:
Help entry for `--disable-cleanup-builddir`
`eb` has an option `--cleanup-builddir` which has the following help text (`--help`):

```
--cleanup-builddir  Cleanup build dir after successful installation. (def True)
```

But I didn't want to clean that directory, so I tried `--cleanup-builddir=False`, which produced the error:

```
eb: error: --cleanup-builddir option does not take a value
```

So I tried `--no-cleanup-builddir`, which wasn't a valid option.

So I then grep-ed the sources, where I found `--disable-cleanup-builddir` as the correct option to use.

Long story short: the software should list `--disable-cleanup-builddir` in the text produced by `--help` (particularly since the only flag listed in the help related to this is the default).


Discussion:
@cwant Thank you very much for the suggestion.

The end of the `--help` output mentions how to disable options that are enabled by default, but we can clearly do better here, it isn't the first time this has popped up...

I'll check if we can convince the option parser to mention how to disable options enabled by default in the help text of those options.

Resolving patch:
diff --git a/easybuild/base/generaloption.py b/easybuild/base/generaloption.py
--- a/easybuild/base/generaloption.py
+++ b/easybuild/base/generaloption.py
@@ -1088,11 +1088,15 @@ def add_group_parser(self, opt_dict, description, prefix=None, otherdefaults=Non
 
             if default is not None:
                 if len(str(default)) == 0:
-                    extra_help.append("def ''")  # empty string
+                    extra_help.append("default: ''")  # empty string
                 elif typ in ExtOption.TYPE_STRLIST:
-                    extra_help.append("def %s" % sep.join(default))
+                    extra_help.append("default: %s" % sep.join(default))
                 else:
-                    extra_help.append("def %s" % default)
+                    extra_help.append("default: %s" % default)
+
+                # for boolean options enabled by default, mention that they can be disabled using --disable-*
+                if default is True:
+                    extra_help.append("disable with --disable-%s" % key)
 
             if len(extra_help) > 0:
                 hlp += " (%s)" % ("; ".join(extra_help))


Test patch:
diff --git a/test/framework/options.py b/test/framework/options.py
--- a/test/framework/options.py
+++ b/test/framework/options.py
@@ -150,7 +150,7 @@ def test_help_long(self):
         topt = EasyBuildOptions(
                                 go_args=['-H'],
                                 go_nosystemexit=True,  # when printing help, optparse ends with sys.exit
-                                go_columns=100,  # fix col size for reproducible unittest output
+                                go_columns=200,  # fix col size for reproducible unittest output
                                 help_to_string=True,  # don't print to stdout, but to StingIO fh,
                                 prog='easybuildoptions_test',  # generate as if called from generaloption.py
                                )
@@ -165,6 +165,10 @@ def test_help_long(self):
         self.assertTrue(re.search("Regression test options", outtxt),
                         "Not all option groups included in short help (2)")
 
+        # for boolean options, we mention in the help text how to disable them
+        regex = re.compile("default: True; disable with --disable-cleanup-builddir", re.M)
+        self.assertTrue(regex.search(outtxt), "Pattern '%s' found in: %s" % (regex.pattern, outtxt))
+
     def test_no_args(self):
         """Test using no arguments."""