How should I structure the argparse to form this? You should be able to call -l,-m,-s,-h,home or work but not both. You should have to call -l or -m before you can use any -i.
usage: prog
(-l | -m ) [-i1][-i2][-i3][-i4]
-s
-h
home
work
can be called using:
prog home
prog work
prog -l -i1
prog -m -i1 -i2
prog -s
The code that I wrote to make something like it.
def get_args():
parser = argparse.ArgumentParser(prog="prog")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-l', action='store_true', help='List Mode. List available options', default=False, dest='list')
group.add_argument('-m', action='store_true', help='Departure Mode. Return a departure time from stopcode or agency and stopname', default=False, dest='mode')
group.add_argument('-s', action='store_true', help='Setup Mode. Enter setup mode to make a home and a work list of station codes.', default=False, dest='setup')
group.add_argument('home', help='Display HOME_LIST') # this causes it to break because positional arguments cant be required for some reason
group.add_argument('work', help='Display WORK_LIST')
parser.add_argument('-i1', nargs='?', dest='i1')
parser.add_argument('-i2', nargs='?', dest='i1')
parser.add_argument('-i3', nargs='?', dest='i1')
return parser.parse_args()