I currently have the following code:
import argparse
parser = argparse.ArgumentParser(description='Adds a new modem to Iridium account')
parser.add_argument('imei', metavar='I', nargs=1, help='the modems IMEI')
parser.add_argument('-t1', '--type1', metavar='t1', nargs=1, choices=('email', 'directip', 'sbddevice'), default='directip', help='Call type (default: directip)')
parser.add_argument('-a1', '--address1', metavar='a1', nargs=1, default='75.101.138.217:9097', help='Call address (default: 75.101.138.217:9097)')
parser.add_argument('-t2', '--type2', metavar='t2', nargs=1, choices=('email', 'directip', 'sbddevice'), help='Call type')
parser.add_argument('-a2', '--address2', metavar='a2', nargs=1, help='Call address')
parser.add_argument('-t3', '--type3', metavar='t3', nargs=1, choices=('email', 'directip', 'sbddevice'), help='Call type')
parser.add_argument('-a3', '--address3', metavar='a3', nargs=1, help='Call address')
parser.add_argument('-t4', '--type4', metavar='t4', nargs=1, choices=('email', 'directip', 'sbddevice'), help='Call type')
parser.add_argument('-a4', '--address4', metavar='a4', nargs=1, help='Call address')
parser.add_argument('-t5', '--type5', metavar='t5', nargs=1, choices=('email', 'directip', 'sbddevice'), help='Call type')
parser.add_argument('-a5', '--address5', metavar='a5', nargs=1, help='Call address')
args = parser.parse_args()
Is there a way I can combine all the -t and -a into say -m1, -m2, -m3, -m4, -m5 where t is the first value of the argument which the same choices below and -a is the second argument but not restricted to the same choices as the first value? It seems like you should be able to do this otherwise you have to do a bunch of checking later on to see if there is a t1 and a1 since if the user provides one they need to provide the other.
So instead of doing -t1 email -a1 [email protected]
you could just do -m1 email [email protected]