I need one group of mutually exclusive parameters is required or not dependents on the value of a parameter, e.g.
I have three parameters -a -b -c
-b, -c are mutually exclusive group
The following commands are some examples ok and not ok:
- python test.py # ok, no parameter is assigned
when -a is assigned a value, -b or -c need to be enabled:
- python test.py -a 100 -b # ok
- python test.py -a 100 -c # ok
- python test.py -a 100 # not ok, b or c is not enabled
- python test.py -a 100 - b -c # not ok, b and c are both enabled
when -a is not assigned a value, -b and -c can't be enabled. Thus the following cases are not ok.
- python test.py -b
- python test.py -c
- python test.py -b -c
Does argparse support this kinds of functions?
If so, how could I achieve it? Thanks!