我有以下的Python代码:
parser = argparse.ArgumentParser(description='Deployment tool')
group = parser.add_mutually_exclusive_group()
group.add_argument('-a', '--add', dest='name_to_add', help='Add a new group or a role to existing group')
group.add_argument('-u', '--upgrade', dest='name_to_upgrade', help='Upgrade a group with the new version')
parser.add_argument('--web_port', help='Port of the WEB instance that is being added to the group')
我的问题是关于"--web_port"选项。我想要只能在使用"-a"选项时添加此选项,而不是在使用"-u"选项时添加。
我希望能够运行:"python my_script.py -a name --web_port=XXXX"。
我不希望能够运行:"python my_script.py -u name --web_port=XXXX"。
我应该如何更改代码以便能够以这种方式运行它?
谢谢,Arshavski Alexander。