I am trying to use my program with command line option. Here is my code:
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-u","--upgrade", help="fully automatized upgrade")
args = parser.parse_args()
if args.upgrade:
print "Starting with upgrade procedure"
main()
When I try to run my program from terminal (python script.py -u), I expect to get the message Starting with upgrade procedure, but instead I get the error message unrecognized arguments -u.
-uwill expect a value or some sort. try doingpython myscript.py -u True