Repository: buildtesters/buildtest (language: python)

Issue:
[FEATURE]: an option to show all subcommands `--help-all`
### Please describe your feature

currently we see all the subcommands when running `buildtest --help`

```console
COMMANDS:
  
    build (bd)          Build and Run test
    buildspec (bc)      Buildspec Interface
    config (cg)         Query buildtest configuration
    report (rt)         Query test report
    inspect (it)        Inspect a test based on NAME or ID
    path                Show path attributes for a given test
    history (hy)        Query build history
    schema              List schema contents and examples
    cdash               Upload test to CDASH server
    unittests (test)    Run buildtest unit tests
    stylecheck (style)  Run buildtest style checks
    cd                  change directory to root of test given a test name
    clean               Remove all generate files from buildtest including
                        test directory, log files, report file, buildspec
                        cache, history files.
    docs                Open buildtest docs in browser
    schemadocs          Open buildtest schema docs in browser
    debugreport (debug)
                        Display system information and additional information
                        for debugging purposes.
    stats               Show test statistics for given test
    info                Show details regarding current buildtest setup
    help (h)            buildtest command guide
    tutorial-examples   Generate documentation examples for Buildtest Tutorial

```

This is going to be an issue going forward as we add more sub-commands. We should add some option let's say `buildtest --help-all` that will show all subcommands. For instance we don't need to show `unittests`, `stylecheck` `docs` `schemadocs` and `tutorial-examples` command since they are used for development purposes. 

That being said the `buildtest --help` should show a subset of the commands and `buildtest --help-all` should show everything. 

# TODO

- [ ] Add option `--help-all` to argparse https://github.com/buildtesters/buildtest/blob/devel/buildtest/cli/__init__.py
- [ ] Add option to [bash completion](https://github.com/buildtesters/buildtest/blob/devel/bash_completion.sh) script
- [ ] Add implementation for `buildtest --help-all` and change behavior of `buildtest --help`  

### Suggest potential solution

_No response_

### Additional Information

_No response_

### Post question in Slack

- [X] I agree that I posted my question in [slack](https://hpcbuildtest.slack.com/) before creating this issue

### Is there an existing issue

- [X] I confirm there is no existing [issue](https://github.com/buildtesters/buildtest/issues) for this issue


Discussion / hints:
@Mendi03 i will assign this issue to you it would be an interesting task for you. I dont personally know the solution for this yet so i would recommend you get familiar with [argparse](https://docs.python.org/3/library/argparse.html) library. 

This feature was kinda inspired by spack if you do `spack help --all`

Fix patch:
diff --git a/bash_completion.sh b/bash_completion.sh
index e00e98d65..eae24c898 100644
--- a/bash_completion.sh
+++ b/bash_completion.sh
@@ -133,7 +133,7 @@ _buildtest ()
 
   COMPREPLY=()   # Array variable storing the possible completions.
 
-  declare -a buildtest_opts=("--color" "--config" "--debug" "--editor" "--help" "--helpcolor" "--logpath" "--loglevel" "--print-log" "--no-color" "--report" "--version" "--view-log" "-c" "-d" "-h" "-l" "-p" "-r" "-V")
+  declare -a buildtest_opts=("--color" "--config" "--debug" "--editor" "--help" "--helpcolor" "--help-all" "--logpath" "--loglevel" "--print-log" "--no-color" "--report" "--version" "--view-log" "-c" "-d" "-h" "-l" "-p" "-r" "-H" "-V")
 
   commands_with_input=( "--color" "--config" "-c" "--report" "-r" "--loglevel" "-l" "--editor" )   # Array variable storing commands which require an input argument from the user.
 
@@ -200,7 +200,7 @@ _buildtest ()
       COMPREPLY=( $( compgen -W "$opts" -- $cur ) )
       ;;
     path)
-      local opts="-b -be -e -h -o -s -t --buildscript --buildenv --errfile --help --outfile --stagedir --testpath"
+      local opts="-b -be -e -h -o -s -t --buildscript --buildenv --errfile --help  --outfile --stagedir --testpath"
       COMPREPLY=( $( compgen -W "$(_builder_names)" -- $cur ) )
       if [[ $cur == -* ]] ; then
         COMPREPLY=( $( compgen -W "$opts" -- $cur ) )
@@ -458,7 +458,7 @@ _buildtest ()
     *)
       local cmds="build buildspec cd cdash clean config debugreport docs help info inspect history path report schema schemadocs stats stylecheck tutorial-examples unittests"
       local alias_cmds="bd bc cg debug it h hy rt style test"
-      local opts="--color --config --debug --editor --help --helpcolor --logpath --loglevel --print-log --no-color --report --version --view-log -c -d -h -l -p -r -V"
+      local opts="--color --config --debug --editor --help --helpcolor --help-all --logpath --loglevel --print-log --no-color --report --version --view-log -c -d -h -l -p -r -H -V"
 
       case "${cur}" in
       # print main options to buildtest


Test patch:
diff --git a/buildtest/cli/__init__.py b/buildtest/cli/__init__.py
index 398d0f1fb..96f5fcdac 100644
--- a/buildtest/cli/__init__.py
+++ b/buildtest/cli/__init__.py
@@ -4,6 +4,7 @@
 """
 import argparse
 import datetime
+import sys
 
 from pygments.styles import STYLE_MAP
 from rich.color import Color, ColorParseError
@@ -12,6 +13,9 @@
 from buildtest.defaults import console
 from buildtest.schemas.defaults import schema_table
 
+# Variables needed to show all sub commands and their help mesaage
+show_all_help = "-H" in sys.argv or "--help-all" in sys.argv
+
 
 def build_filters_format(val):
     """This method is used as validate argument type for ``buildtest build --filter``.
@@ -260,6 +264,9 @@ def get_parser():
         help="Print available color options in a table format.",
     )
     parser.add_argument("-r", "--report", help="Specify path to test report file")
+    parser.add_argument(
+        "-H", "--help-all", help="List all commands and options", action="help"
+    )
 
     subparsers = parser.add_subparsers(title="COMMANDS", dest="subcommands", metavar="")
 
@@ -328,6 +335,10 @@ def get_parent_parser():
     misc_menu(subparsers)
     tutorial_examples_menu(subparsers)
 
+    # Displays all hidden comands
+    if show_all_help:
+        help_all(subparsers)
+
     return parser
 
 
@@ -338,6 +349,10 @@ def misc_menu(subparsers):
         subparsers (argparse._SubParsersAction): Subparser object to add subparser
     """
 
+    # Subcommands that do not need to be shown in ``--help``
+    subparsers.add_parser("docs")
+    subparsers.add_parser("schemadocs")
+
     cd_parser = subparsers.add_parser(
         "cd", help="change directory to root of test given a test name"
     )
@@ -353,8 +368,6 @@ def misc_menu(subparsers):
         "-y", "--yes", action="store_true", help="Confirm yes for all prompts"
     )
 
-    subparsers.add_parser("docs", help="Open buildtest docs in browser")
-    subparsers.add_parser("schemadocs", help="Open buildtest schema docs in browser")
     subparsers.add_parser(
         "debugreport",
         help="Display system information and additional information for debugging purposes.",
@@ -405,9 +418,8 @@ def stylecheck_menu(subparsers):
         subparsers (argparse._SubParsersAction): Subparser object to add subparser
     """
 
-    stylecheck_parser = subparsers.add_parser(
-        "stylecheck", aliases=["style"], help="Run buildtest style checks"
-    )
+    # Subcommands that do not need to be shown in ``--help``
+    stylecheck_parser = subparsers.add_parser("stylecheck", aliases=["style"])
 
     stylecheck_parser.add_argument(
         "--no-black", action="store_true", help="Don't run black style check"
@@ -430,9 +442,9 @@ def unittest_menu(subparsers):
         subparsers (argparse._SubParsersAction): Subparser object to add subparser
     """
 
-    unittests_parser = subparsers.add_parser(
-        "unittests", help="Run buildtest unit tests", aliases=["test"]
-    )
+    # Subcommands that do not need to be shown in --help
+    unittests_parser = subparsers.add_parser("unittests", aliases=["test"])
+
     unittests_parser.add_argument(
         "-c",
         "--coverage",
@@ -458,10 +470,7 @@ def tutorial_examples_menu(subparsers):
         subparsers (argparse._SubParsersAction): Subparser object to add subparser
     """
 
-    subparsers.add_parser(
-        "tutorial-examples",
-        help="Generate documentation examples for Buildtest Tutorial",
-    )
+    subparsers.add_parser("tutorial-examples")
 
 
 def path_menu(subparsers):
@@ -1295,3 +1304,26 @@ def cdash_menu(subparsers):
     upload.add_argument(
         "-o", "--open", action="store_true", help="Open CDASH report in browser"
     )
+
+
+def help_all(subparsers):
+    """This method will add parser for hidden command that can be shown when using ``--help-all/-H``
+
+    Args:
+        subparsers (argparse._SubParsersAction): Subparser object
+    """
+    hidden_parser = {
+        "tutorial-examples": "Generate documentation examples for Buildtest Tutorial",
+        "docs": "Open buildtest docs in browser",
+        "schemadocs": "Open buildtest schema docs in browser",
+        "unittests": {"help": "Run buildtest unit tests", "aliases": ["test"]},
+        "stylecheck": {"help": "Run buildtest style checks", "aliases": ["style"]},
+    }
+
+    for command, val in hidden_parser.items():
+        if type(val) is dict:
+            subparsers.add_parser(
+                command, help=val.get("help"), aliases=val.get("aliases")
+            )
+        else:
+            subparsers.add_parser(command, help=val)