having a code like below
>>> import argparse
>>> parser=argparse.ArgumentParser()
>>> parser.add_argument('must_have', help='this is a required arg')
>>> parser.add_argument('-o', '--optional', help='some optional arg')
>>> parser.add_argument('--others', nargs=argparse.REMAINDER, help='some other options')
and displaying help will display sth like:
usage: [-h] [-o OPTIONAL] [--others ...] must_have
positional arguments:
must_have this is a required arg
optional arguments:
-h, --help show this help message and exit
-o OPTIONAL, --optional OPTIONAL
some optional arg
--others ... some other options
which is clearly misleading, cause passing arguments in the order like in help will cause an error:
>>> parser.parse_args(['-o', 'foo', '--others', 'foo=1', 'bar=2', 'ye_mandatory_arg'])
usage: [-h] [-o OPTIONAL] [--others ...] must_have
: error: the following arguments are required: must_have
which of course sounds right. and to make it work we have to pass the mandatory positional arg before the one using REMAINDER:
>>> parser.parse_args(['-o', 'foo', 'ye-mandatory-arg', '--others', 'foo=1', 'bar=2'])
Namespace(must_have='ye-mandatory-arg', optional='foo', others=['foo=1', 'bar=2'])
Is it even possible to fix the help message?