One nice feature of GCC's command line parsing is that most flags of the form "-fmy-option" have a negative version called "-fno-my-option". The rightmost occurrence takes precedence, so you can just append "-fno-my-option" to your CFLAGS or similar in a Makefile to disable an option without clobbering the other flags.
I'd like to support something similar in a tool whose wrapper script is Python and uses argparse. The obvious hack of just defining both versions of the argument with an action of store_true doesn't work, because that won't let me ask for the rightmost occurrence.
Obviously, it's easy to support a syntax like --my-option=yes / --my-option=no, but it would be nice for the user not to have to pass the parameter.
Is there a way to get argparse to have an on/off switch for a boolean flag like this?