Skip to content
Snippets Groups Projects
Commit de698eeb authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

refactor main with subparsers

parent ee52ca10
No related branches found
No related tags found
2 merge requests!19Move linux-debian11 into main,!1Resolve "First draft for user interface for top level install command"
......@@ -113,71 +113,15 @@ def prepare_env(toolchain_base_dir, mpsd_spack_ver, skip_dir_check, shared_var):
def main():
parser = argparse.ArgumentParser(description=about_tool)
parser.add_argument(
"--release", type=str, help="Specify the release version to install"
)
parser.add_argument(
"--target-directory",
type=str,
help="Specify the target directory for installation (use DEFAULT to use /opt_mpsd/<MPSD_OS>/<MPSD_RELEASE>/<MPSD_MICROARCH)",
)
parser.add_argument(
"--install",
nargs="+",
help="Specify toolchain(s) to install eg foss2021a-mpi (use ALL to install all available toolchains)",
)
parser.add_argument("--remove", type=str, help="Specify toolchain to remove")
parser.add_argument(
"--set-up",
type=str,
help="Start a new software environment version, must specify --from <release>",
)
parser.add_argument(
"--from",
dest="from_release",
type=str,
help="Specify the release version to start from",
)
parser.add_argument(
"--force-reinstall",
action="store_true",
help="Delete and reinstall an existing toolchain directory",
)
parser.add_argument(
"--skip-build-cache",
action="store_true",
help="Skip Spack build cache during installation",
)
parser.add_argument(
"--skip-dir-check",
action="store_true",
help="Skip checking if the target directory already exists",
)
args = parser.parse_args()
if args.release is None:
parser.print_help()
sys.exit(1)
if args.remove:
cmd = "remove"
elif args.set_up:
cmd = "start_new"
else:
if args.install:
cmd = "install"
else:
cmd = "prepare_env"
run = builder(
release=args.release,
cmd=cmd,
toolchain_list=args.install,
target_dir=args.target_directory,
# force_reinstall=args.force_reinstall,
skip_build_cache=args.skip_build_cache,
)
run.run()
# Add subparsers for different actions
subparsers = parser.add_subparsers(dest='action', title='actions', description='valid actions', required=True)
# Add parser for "install" action
parser_install = subparsers.add_parser('install', help='Install a software environment')
parser_install.add_argument('--release', type=str, required=True, help='Release version to install')
parser_install.add_argument('--target-dir', type=str, help='Target directory for installation (use DEFAULT to install to default directory)')
parser_install.add_argument('--force-reinstall', action='store_true', help='Force reinstall an existing toolchain directory')
parser_install.add_argument('--skip-build-cache', action='store_true', help='Skip Spack build cache during installation')
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment