in protool/command_line.py [0:0]
def _handle_arguments() -> int:
"""Handle command line arguments and call the correct method."""
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
diff_parser = subparsers.add_parser(
"diff", help="Perform a diff between two profiles"
)
diff_parser.add_argument(
"-i",
"--ignore",
dest="ignore",
action="store",
nargs="+",
default=None,
help="A list of keys to ignore. e.g. --ignore TimeToLive UUID",
)
diff_parser.add_argument(
"-t",
"--tool",
dest="tool",
action="store",
default=None,
help="Specify a diff command to use. It should take two file paths as the final two arguments. Defaults to opendiff", # pylint: disable=line-too-long
)
diff_parser.add_argument(
"-p",
"--profiles",
dest="profiles",
action="store",
nargs=2,
required=True,
help="The two profiles to diff",
)
diff_parser.add_argument(
"-k",
"--keep-original-order",
dest="keep_original_order",
action="store_true",
required=False,
default=False,
help="Set to avoid sorting keys for diff operations",
)
diff_parser.set_defaults(subcommand="diff")
gitdiff_parser = subparsers.add_parser(
"gitdiff",
help="Perform a diff between two profiles with the git diff parameters",
)
gitdiff_parser.add_argument(
"-i",
"--ignore",
dest="ignore",
action="store",
nargs="+",
default=None,
help="A list of keys to ignore. e.g. --ignore TimeToLive UUID",
)
gitdiff_parser.add_argument(
"-t",
"--tool",
dest="tool",
action="store",
default=None,
help="Specify a diff command to use. It should take two file paths as the final two arguments. Defaults to opendiff", # pylint: disable=line-too-long
)
gitdiff_parser.add_argument(
"-g",
"--git-args",
dest="git_args",
action="store",
nargs=7,
required=True,
help="The arguments from git",
)
gitdiff_parser.set_defaults(subcommand="gitdiff")
read_parser = subparsers.add_parser(
"read", help="Read the value from a profile using the key specified command"
)
read_parser.add_argument(
"-p",
"--profile",
dest="profile",
action="store",
required=True,
help="The profile to read the value from",
)
read_parser.add_argument(
"-k",
"--key",
dest="key",
action="store",
required=True,
help="The key to read the value for",
)
read_parser.set_defaults(subcommand="read")
decode_parser = subparsers.add_parser(
"decode", help="Decode a provisioning profile and display in a readable format"
)
decode_parser.add_argument(
"-p",
"--profile",
dest="profile",
action="store",
required=True,
help="The profile to read the value from",
)
decode_parser.set_defaults(subcommand="decode")
args = parser.parse_args()
try:
_ = args.subcommand
except Exception:
parser.print_help()
return 1
if args.subcommand == "diff":
return _handle_diff(args)
if args.subcommand == "gitdiff":
return _handle_git_diff(args)
if args.subcommand == "read":
return _handle_read(args)
if args.subcommand == "decode":
return _handle_decode(args)
print("Unrecognized command")
return 1