diff --git a/mpsd-software.py b/mpsd-software.py index bfeb5a5bf6476b23c357461cbf2f6af8cdf3277b..f82bf7d60f1ac2ecf1be803e5c2514e95c83a241 100755 --- a/mpsd-software.py +++ b/mpsd-software.py @@ -26,13 +26,41 @@ else: rich_available = True -about_tool = """ +about_intro = f""" Build toolchains using Spack.\n -This function builds toolchains for MPSD-HPC at the appropriate directory, \n -for given system architecture and MPSD software stack version.\n -The toolchains -are built using the bash script spack_setup.sh, and the results are logged. """ +This function builds toolchains for MPSD-HPC at the appropriate directory, +for given system architecture and MPSD software stack version. The toolchains +are built using the bash script spack_setup.sh, and the results are logged. + +Command line usage: + + $> {sys.argv[0]} + +""" + + +about_epilog = f""" + + +Examples: + +1. Query what package sets and toolchains are available in relase dev-23a + + $> {sys.argv[0]} available dev-23a + +2. Install foss2022a-serial toolchain + + $> {sys.argv[0]} install dev-23a foss2022a-serial + +3. Check what package sets and toolchains are installed from release dev-23a + + $> {sys.argv[0]} status dev-23a + +Documentation: https://gitlab.gwdg.de/mpsd-cs/mpsd-software/-/blob/main/README.rst + +""" + call_date_iso = ( datetime.datetime.now().replace(microsecond=0).isoformat().replace(":", "-") @@ -1032,7 +1060,11 @@ def environment_status(mpsd_release: str, root_dir: Union[str, Path]) -> dict: def main(): """Execute main entry point.""" - parser = argparse.ArgumentParser(description=about_tool) + parser = argparse.ArgumentParser( + description=about_intro, + epilog=about_epilog, + formatter_class=argparse.RawDescriptionHelpFormatter, + ) parser.add_argument( "--log", "-l", @@ -1086,20 +1118,14 @@ def main(): if cmd in ["install", "reinstall", "remove"]: # "install" command needs additional documentation tool_chain_help = ( - f"Pass a list of toolchains to command {cmd}. " - "Use '--toolchains ALL' to " - f"{cmd} all toolchains. If '--toolchain' is not " - "specified, list available toolchains for the release " - "(after environment has been prepared if not done yet)." + f"One or more toolchains to command {cmd}. " + "Use 'ALL' to refer to all available toolchains." ) subp.add_argument( - "--toolchains", # first option defines attribute - # name `args.toolchains` in `args = parser_args()` - "--toolchain", # allow singular as alternative - # (-> creates attribute `args.toolchains` if used) + "toolchain", # first option defines attribute + # name `args.toolchain` in `args = parser_args()` type=str, - dest="toolchains", nargs="+", default="NONE", help=tool_chain_help, @@ -1133,12 +1159,12 @@ def main(): # Check the command and run related function if args.action == "remove": - remove_environment(args.release, args.toolchains, root_dir) + remove_environment(args.release, args.toolchain, root_dir) elif args.action == "start-new": start_new_environment(args.from_release, args.to_release, root_dir) elif args.action == "install": install_environment( - args.release, args.toolchains, root_dir, args.enable_build_cache + args.release, args.toolchain, root_dir, args.enable_build_cache ) elif args.action == "status": _ = environment_status(args.release, root_dir)