I'm using the argparse
module to get two optional command line arguments:
parser.add_argument('start_date', nargs='?', metavar='START DATE',
help='start date in YYYY-MM-DD')
parser.add_argument('end_date', nargs='?', metavar='END DATE',
help='end date in YYYY-MM-DD')
which gives
> python test_arg.py -h
usage: test_arg.py [-h] [START DATE] [END DATE]
However I want the pair of optional arguments (START DATE
and END DATE
), if provided at all, to be provided together. Something like along this line:
usage: test_arg.py [-h] [START_DATE END_DATE]
Is it possible with argparse
?