I'm using argparse module in Python to parse parameters typed in a command line interface. I have the following add_argument call to a subparser object:
submit_parser.add_argument('-pv','--provision',metavar='PROVISION', dest='PROVISION',
help='provision system',
action='store_true', default=False, required=False)
I get this error:
Traceback (most recent call last):
File "./scripts/tp4", line 94, in <module>
main()
File "./scripts/tp4", line 74, in main
modloader.loadModules(sub_parsers)
File "/usr/lib/python2.6/site-packages/tp4/cli/Moduleloader.py", line 66, in loadModules
registered_modules[module_name].setSubparserArgs(module_sub_parser)
File "/usr/lib/python2.6/site-packages/tp4/cli/modules/AutotestModule.py", line 135, in setSubparserArgs
action='store_true', default=False, required=False)
File "/usr/share/tp4/cli/zip/argparse.zip/argparse.py", line 1302, in add_argument
TypeError: __init__() got an unexpected keyword argument 'metavar'
If I remove action or metavar parameters, it works. Why both can't be together? There is nothing about this restriction in argparse documentation at http://docs.python.org/dev/library/argparse.html.
Thanks in advance for any help