# HG changeset patch # User Franz Glasner # Date 1735920269 -3600 # Node ID 17d6e760143fd82e06ed16b6042d7bbbf19163a6 # Parent ed35f3c9e2b5a7ad4ee691b63ed273533c639d8c Optimize help / usage output for the global options. Use an argparser group and let disable automatic "-h/--help" arguments. diff -r ed35f3c9e2b5 -r 17d6e760143f cutils/treesum.py --- 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(