I have a code that I am using argparse and I want to use add_mutually_exclusive_group
in 2 subparsers because I want one of the 2 to be required, and I get this error:
AttributeError: '_SubParsersAction' object has no attribute 'add_mutually_exclusive_group'
this is my code:
import argparse as ap
main = ap.ArgumentParser()
modes = main.add_subparsers()
modesp = modes.add_mutually_exclusive_group(required=True)
a = modesp.add_parser('a')
b = modesp.add_parser('b')
a.add_argument('--start')
a.add_argument('--stop')
a.add_argument('--reset')
b.add_argument('--start')
b.add_argument('--stop')
b.add_argument('--reset')
main.parse_args()