Message132327
So it strikes me that there already exists an officially supported way to rename your option groups. Just only create your own option groups (never use the default ones) and only put arguments there, e.g.:
------------------------- temp.py --------------------------
parser = argparse.ArgumentParser(description = 'Do something', add_help=False)
flags = parser.add_argument_group('flag arguments')
flags.add_argument('-h', '--help', action='help')
flags.add_argument('--reqarg', '-r', help='This is required', required=True)
flags.add_argument('--optarg','-o', help="This is optional", required=False)
args = parser.parse_args()
------------------------------------------------------------
$ python temp.py --help
usage: temp.py [-h] --reqarg REQARG [--optarg OPTARG]
Do something
flag arguments:
-h, --help
--reqarg REQARG, -r REQARG
This is required
--optarg OPTARG, -o OPTARG
This is optional
------------------------------------------------------------
The documentation for action='help' needs to be added, as pointed out in Issue# 10772.
So basically, the API for customizing group names is already there. So I'm changing this to a documentation request - there should be an example in the docs showing how to change the default group names as above. |
|
Date |
User |
Action |
Args |
2011-03-27 14:20:43 | bethard | set | recipients:
+ bethard, terry.reedy, eric.smith, eric.araujo, r.david.murray, docs@python, benschmaus |
2011-03-27 14:20:43 | bethard | set | messageid: <1301235643.57.0.25546309368.issue9694@psf.upfronthosting.co.za> |
2011-03-27 14:20:43 | bethard | link | issue9694 messages |
2011-03-27 14:20:42 | bethard | create | |
|