62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
"""Manages the CLI component of the tool."""
|
|
|
|
import argparse
|
|
|
|
|
|
def parse_inputs() -> argparse.Namespace:
|
|
"""Parse inputs from argparse.
|
|
|
|
:returns the argparse Namespace to be evaluated
|
|
"""
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("flake_path", metavar="flake-path", help="path to flake to evaluate")
|
|
parser.add_argument("--keep-hydra", action="store_true", help="retain Hydra jobs")
|
|
parser.add_argument("--build", action="store_true", help="allow building Hydra jobs")
|
|
parser.add_argument("--evaluate", action="store_true", help="allow evaluating Hydra jobs")
|
|
parser.add_argument(
|
|
"--json", metavar="json-path", help="whether or not to output evaluations to a json"
|
|
)
|
|
parser.add_argument(
|
|
"--compare-drvs",
|
|
action="store_true",
|
|
help="whether to compare two drv sets, must provide two evaluation jsons to compare",
|
|
)
|
|
parser.add_argument(
|
|
"--compare-pre-json",
|
|
metavar="pre-json-path",
|
|
default=None,
|
|
help="location of pre.json for comparison. defaults to <flake_path>/pre.json",
|
|
)
|
|
parser.add_argument(
|
|
"--compare-post-json",
|
|
metavar="post-json-path",
|
|
default=None,
|
|
help="location of post.json for comparison. defaults to <flake_path>/post.json",
|
|
)
|
|
parser.add_argument(
|
|
"--compare-output-to-file",
|
|
action="store_true",
|
|
help="whether to output comparison output to a file",
|
|
)
|
|
parser.add_argument(
|
|
"--compare-output-file",
|
|
metavar="compare-output-file-path",
|
|
default=None,
|
|
help="location of comparison output. defaults to <flake_path>/post-diff. implies --compare-output-to-file.",
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
if args.compare_pre_json is None:
|
|
args.compare_pre_json = args.flake_path + "/pre.json"
|
|
|
|
if args.compare_post_json is None:
|
|
args.compare_post_json = args.flake_path + "/post.json"
|
|
|
|
if args.compare_output_to_file and args.compare_output_file is None:
|
|
args.compare_output_file = args.flake_path + "/post-diff"
|
|
|
|
if args.compare_output_file is not None:
|
|
args.compare_output_to_file = True
|
|
|
|
return args
|