Feature or enhancement
Proposal:
Currently, Python’s argparse module supports mutually exclusive groups at a single level, meaning you can enforce constraints like:
However, there is no built-in way to express nested or dependent exclusivity, such as:
In this case, if argument c is provided, d must also be provided, but a and b remain mutually exclusive with the combination (c and d).
Result:
This would allow developers to write complex argument logic withou writing code manually for such validation: I actually needed for a cli app. This would be something like:
# Valid
mytool.py --a
mytool.py --b
mytool.py --c --d
# Invalid
mytool.py --c # missing --d
mytool.py --c --d --a # mutually exclusive with a
Feature or enhancement
Proposal:
Currently, Python’s argparse module supports mutually exclusive groups at a single level, meaning you can enforce constraints like:
However, there is no built-in way to express nested or dependent exclusivity, such as:
In this case, if argument c is provided, d must also be provided, but a and b remain mutually exclusive with the combination (c and d).
Result:
This would allow developers to write complex argument logic withou writing code manually for such validation: I actually needed for a cli app. This would be something like: