Set up mutually exclusive sets in argparse
argparse, python
Solution
Not an answer that uses argparse, but a possible solution to your problem nonetheless: using docopt instead of argparse would let you just write your usage patterns, and let docopt automatically parse and validate the args passed to your program. In your case,
prog_name (--conf CONF | --hostname HOST --port PORT)
would get you the mutually exclusive group you want.
Problem
I'm using a mutually exclusive group, but I more than one option to be in one of the exclusive sets. I want my usage to look like this: ``` [--conf CONF | --hostname HOSTNAME --port PORT] ``` Any idea how to accompish this? I've tried adding an argument group to a mutually exclusive group, but the mutual exclusion part doesn't apply to subgroups, and it allows `--conf file --hostname host --port 22`