Use optional arguments for setting repositories

This commit is contained in:
Darryl Green 2019-03-01 09:54:44 +00:00
parent ddf25a6095
commit c5132ffc41

View File

@ -372,26 +372,34 @@ def run_main():
help="keep all reports, even if there are no compatibility issues", help="keep all reports, even if there are no compatibility issues",
) )
parser.add_argument( parser.add_argument(
"-o", "--old-rev", type=str, "-o", "--old-rev", type=str, help="revision for old version.",
help=("revision for old version." required=True,
"Can include repository before revision"),
required=True, nargs="+"
) )
parser.add_argument( parser.add_argument(
"-oc", "--old-crypto-rev", type=str, nargs="+", "-or", "--old-repo", type=str, help="repository for old version."
help=("revision for old crypto version."
"Can include repository before revision"),
) )
parser.add_argument( parser.add_argument(
"-n", "--new-rev", type=str, "-oc", "--old-crypto-rev", type=str,
help=("revision for new version" help="revision for old crypto submodule."
"Can include repository before revision"),
required=True, nargs="+"
) )
parser.add_argument( parser.add_argument(
"-nc", "--new-crypto-rev", type=str, nargs="+", "-ocr", "--old-crypto-repo", type=str,
help=("revision for new crypto version" help="repository for old crypto submodule."
"Can include repository before revision"), )
parser.add_argument(
"-n", "--new-rev", type=str, help="revision for new version",
required=True,
)
parser.add_argument(
"-nr", "--new-repo", type=str, help="repository for new version."
)
parser.add_argument(
"-nc", "--new-crypto-rev", type=str,
help="revision for new crypto version"
)
parser.add_argument(
"-ncr", "--new-crypto-repo", type=str,
help="repository for new crypto submodule."
) )
parser.add_argument( parser.add_argument(
"-s", "--skip-file", type=str, "-s", "--skip-file", type=str,
@ -402,46 +410,12 @@ def run_main():
help="output only the list of issues to stdout, instead of a full report", help="output only the list of issues to stdout, instead of a full report",
) )
abi_args = parser.parse_args() abi_args = parser.parse_args()
if len(abi_args.old_rev) == 1:
old_repo = None
old_rev = abi_args.old_rev[0]
elif len(abi_args.old_rev) == 2:
old_repo = abi_args.old_rev[0]
old_rev = abi_args.old_rev[1]
else:
raise Exception("Too many arguments passed for old version")
if len(abi_args.new_rev) == 1:
new_repo = None
new_rev = abi_args.new_rev[0]
elif len(abi_args.new_rev) == 2:
new_repo = abi_args.new_rev[0]
new_rev = abi_args.new_rev[1]
else:
raise Exception("Too many arguments passed for new version")
old_crypto_repo = None
old_crypto_rev = None
if abi_args.old_crypto_rev:
if len(abi_args.old_crypto_rev) == 1:
old_crypto_rev = abi_args.old_crypto_rev[0]
elif len(abi_args.old_crypto_rev) == 2:
old_crypto_repo = abi_args.old_crypto_rev[0]
old_crypto_rev = abi_args.old_crypto_rev[1]
else:
raise Exception("Too many arguments passed for old crypto version")
new_crypto_repo = None
new_crypto_rev = None
if abi_args.new_crypto_rev:
if len(abi_args.new_crypto_rev) == 1:
new_crypto_rev = abi_args.new_crypto_rev[0]
elif len(abi_args.new_crypto_rev) == 2:
new_crypto_repo = abi_args.new_crypto_rev[0]
new_crypto_rev = abi_args.new_crypto_rev[1]
else:
raise Exception("Too many arguments passed for new crypto version")
abi_check = AbiChecker( abi_check = AbiChecker(
abi_args.report_dir, old_repo, old_rev, old_crypto_rev, abi_args.report_dir, abi_args.old_repo, abi_args.old_rev,
old_crypto_repo, new_repo, new_rev, new_crypto_rev, new_crypto_repo, abi_args.old_crypto_rev, abi_args.old_crypto_repo,
abi_args.keep_all_reports, abi_args.brief, abi_args.skip_file abi_args.new_repo, abi_args.new_rev, abi_args.new_crypto_rev,
abi_args.new_crypto_repo, abi_args.keep_all_reports,
abi_args.brief, abi_args.skip_file
) )
return_code = abi_check.check_for_abi_changes() return_code = abi_check.check_for_abi_changes()
sys.exit(return_code) sys.exit(return_code)