diff cutils/treesum.py @ 148:17d6e760143f

Optimize help / usage output for the global options. Use an argparser group and let disable automatic "-h/--help" arguments.
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 03 Jan 2025 17:04:29 +0100
parents ed35f3c9e2b5
children f717854be1de
line wrap: on
line diff
--- a/cutils/treesum.py	Fri Jan 03 16:51:26 2025 +0100
+++ b/cutils/treesum.py	Fri Jan 03 17:04:29 2025 +0100
@@ -90,20 +90,32 @@
 
     parser = argparse.ArgumentParser(
         description="Generate and verify checksums for directory trees.",
-        fromfile_prefix_chars='@')
+        fromfile_prefix_chars='@',
+        add_help=False)
 
+    #
     # Global options for all sub-commands
-    parser.add_argument(
+    #
+    gparser = parser.add_argument_group(title="Global Options")
+    gparser.add_argument(
         "-v", "--version", action="version",
-        version="%s (rv:%s)" % (__version__, __revision__))
+        version="%s (rv:%s)" % (__version__, __revision__),
+        help="Show program's version number and exit")
+    gparser.add_argument(
+        "-h", "--help", action="help",
+        help="Show this help message and exit")
 
+    #
+    # Subcommands
+    #
     subparsers = parser.add_subparsers(
         dest="subcommand",
         title="Commands",
         description="This tool uses subcommands. "
                     "To see detailed help for a specific subcommand use "
                     "the -h/--help option after the subcommand name. "
-                    "A short list of valid commands are listed below:",
+                    "A list of valid commands and their short descriptions "
+                    "is listed below:",
         metavar="COMMAND")
 
     genparser = subparsers.add_parser(