Why when I do a simple store, does it goof up the help menu? It's adding the all caps destination for some reason and I dont know how to turn it off. Below you can see the difference. The first is using store_const which doesn't goof up the help menu, but of course doesn't suit my needs. The second is the simple store. See the difference?
Constant Store
dev@taco:~/argparse$ python3 arg-0.0.1.py -h
usage: arg-0.0.1.py [-h] [-s] [-e] [-v]
Example list of options
optional arguments:
-h, --help show this help message and exit
-s, --start enter the starting value
-e, --end enter the ending value
-v, --version show program's version number and exit
Simple Store
dev@taco:~/argparse$ python3 arg-0.0.1.py -h
usage: arg-0.0.1.py [-h] [-s START] [-e END] [-v]
Example list of options
optional arguments:
-h, --help show this help message and exit
-s START, --start START
enter the starting value
-e END, --end END enter the ending value
-v, --version show program's version number and exit
Here is the actual code for both simple and constant:
#! /usr/bin/env python3
import argparse
parser = argparse.ArgumentParser(description='Example list of options', add_help=True)
parser.add_argument('-s', '--start', dest='start', action='store_const', const='1', help='enter the starting value')
parser.add_argument('-e', '--end', dest='end', action='store_const', const='1000', help='enter the ending value')
parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.0.1')
results = parser.parse_args()
print ('Starting value = ', results.start)
print ('Ending value = ', results.end)
#! /usr/bin/env python3
import argparse
parser = argparse.ArgumentParser(description='Example list of options', add_help=True)
parser.add_argument('-s', '--start', dest='start', action='store', help='enter the starting value')
parser.add_argument('-e', '--end', dest='end', action='store', help='enter the ending value')
parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.0.1')
results = parser.parse_args()
print ('Starting value = ', results.start)
print ('Ending value = ', results.end)
Perhaps this is just expected and the reason it is adding START and END is to tell the user that the flag expects an argument. Its just a little confusing. Also, since it word wraps the menu, it makes it difficult to read at first.
How can I clean up the menu? Perhaps suggest a way to increase the size of the help menu to fix the word wrap issue first and then if possible, maybe also a way to change START and END to something else that is easier to understand. Maybe <value>?
os.environ['COLUMNS']metavar='<value>'parameter to change the default uppercase form. docs.python.org/3/library/argparse.html#metavar