argparse
extensions.
pip install argparse-extensions
argparse.BooleanOptionalAction
action=argparse_extensions.NegatableStoreTrueAction
is a drop-in replacement
for action='store_true'
:
parser = argparse.ArgumentParser()
parser.add_argument(
'--foo',
action=argparse_extensions.NegatableStoreTrueAction)
This will handle --no-foo
in addition to --foo
.