mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Use argparse instead of the deprecated optparse
This commit is contained in:
parent
75ac98bd45
commit
d86fcbe5c6
1 changed files with 15 additions and 25 deletions
|
@ -5,7 +5,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from optparse import OptionParser
|
import argparse
|
||||||
|
|
||||||
from utils import git
|
from utils import git
|
||||||
|
|
||||||
|
@ -212,38 +212,28 @@ def createVersionBranches(version):
|
||||||
if is_patch_release:
|
if is_patch_release:
|
||||||
print("[SUCCESS] NOTE: You will have to wait for the first fix to be merged into the RC branch to be able to create the PR")
|
print("[SUCCESS] NOTE: You will have to wait for the first fix to be merged into the RC branch to be able to create the PR")
|
||||||
|
|
||||||
def usage():
|
|
||||||
"""Print usage."""
|
|
||||||
print("rc-branches.py supports the following commands:")
|
|
||||||
print("\ncheck <version>")
|
|
||||||
print(" <version> - version to check of the form \"X.Y.Z\"")
|
|
||||||
print("\ncreate <version>")
|
|
||||||
print(" <version> - version to create branches for of the form \"X.Y.Z\"")
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Execute Main entry point."""
|
"""Execute Main entry point."""
|
||||||
global remote_name
|
global remote_name
|
||||||
|
|
||||||
parser = OptionParser()
|
parser = argparse.ArgumentParser(description='RC branches tool',
|
||||||
parser.add_option("-r", "--remote", type="string", dest="remote_name", default=remote_name)
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
(options, args) = parser.parse_args(args=sys.argv)
|
epilog='''Example commands you can run:\n%(prog)s check 0.75.0\n%(prog)s create 0.75.1''')
|
||||||
|
parser.add_argument("command", help="command to execute", choices=["check", "create"])
|
||||||
|
parser.add_argument("version", help="version of the form \"X.Y.Z\"")
|
||||||
|
parser.add_argument("--remote", dest="remote_name", default=remote_name,
|
||||||
|
help="git remote to use as reference")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
remote_name = options.remote_name
|
remote_name = args.remote_name
|
||||||
|
|
||||||
if len(args) < 3:
|
|
||||||
usage()
|
|
||||||
return
|
|
||||||
|
|
||||||
command = args[1]
|
|
||||||
version = args[2]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if command == "check":
|
if args.command == "check":
|
||||||
checkVersionBranches(version)
|
checkVersionBranches(args.version)
|
||||||
elif command == "create":
|
elif args.command == "create":
|
||||||
createVersionBranches(version)
|
createVersionBranches(args.version)
|
||||||
else:
|
else:
|
||||||
usage()
|
parser.print_help()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in a new issue