I am writing a script using python and argparse:
import argparse
parser = prgparse.ArgumentParser(description="do a or b")
parser.add_argument("-a", "--funcA", help="do A")
parser.add_argument("-b", "--funcB", help="do B")
args = parser.parse_args()
if args.funcA:
print(args.funcA)
if args.funcB:
print(args.funcB)
I want to be able to run it with python3 parseab.py -a 11 -b 22 -a 33
, and that funcA will be performed twice with 11 and 33, and funcB once with 22.
Right now each function is happening only once.
*I do not want to be able to accept more arguments after each option, but to be able to accept several instances of the same function.
Thank you!