I want to be able to --install or --uninstall and use those argument names but argparse to interpret them as bool values. In addition how would I best validate or limit the named arguments to only --install/--uninstall
What I don't want to do is --uninstall True or --uninstall False bool values should not be not specified by the user but assumed/default based on argument name
call python register.py --install
call python register.py --uninstall
parser = argparse.ArgumentParser(description="install or uninstall file")
parser.add_argument("--install", action="store_true", help="Register file") # should be False
parser.add_argument("--uninstall", action="store_true", help="Uninstall file") # should be true
args = parser.parse_args()
if not args.install and not args.uninstall: # better way to do this?
parser.error("Please specify --register or --uninstall")
if args.install and args.uninstall:
parser.error("Please specify only one option --register or --Uninstall")
modify_ini(ini, "Global Clients", ".test", "testme", remove_key=args) # in modify_ini the remove_key argument adds or remove ini configurations