Python argparse required?
So, two things:
- In the general case, this is done with
add_mutually_exclusive_group(required=True)
and adding the mutually exclusive arguments to that group (this isn't exactly what you want, since it won't allow you to pass both, but it's close enough). - In this specific case, you should be using the
action='version'
action for displaying the version, which exists specifically for this purpose, and leave-f
plainrequired=True
as you've already written it.