I’m using ArgumentParser
to document the usage of a complicated program. Since the program has several long lists of capabilities, it requires several --help
arguments.
My current ArgumentParser
looks like this.
<code>parser = ArgumentParser(description = 'Complicated program')
parser.add_argument('--list-models', action = 'store_true', help = 'List the available models')
parser.add_argument('--list-stuff', action = 'store_true', help = 'List the other stuff')
# ...
parser.add_argument('important_data', help = 'Some important data that is required')
</code>
<code>parser = ArgumentParser(description = 'Complicated program')
parser.add_argument('--list-models', action = 'store_true', help = 'List the available models')
parser.add_argument('--list-stuff', action = 'store_true', help = 'List the other stuff')
# ...
parser.add_argument('important_data', help = 'Some important data that is required')
</code>
parser = ArgumentParser(description = 'Complicated program')
parser.add_argument('--list-models', action = 'store_true', help = 'List the available models')
parser.add_argument('--list-stuff', action = 'store_true', help = 'List the other stuff')
# ...
parser.add_argument('important_data', help = 'Some important data that is required')
I want --list-models
and --list-stuff
to print some data and exit, similar to how --help
works.
However, running the program with either argument fails since important_data
is a positional argument, which ArgumentParser
always requires.
What’s the nicest way to implement this help pattern?