diff --git a/lib/jcsda-emc/spack-stack/stack/cmd/stack_cmds/create.py b/lib/jcsda-emc/spack-stack/stack/cmd/stack_cmds/create.py index ef93d78b45218e..b9611393f02049 100644 --- a/lib/jcsda-emc/spack-stack/stack/cmd/stack_cmds/create.py +++ b/lib/jcsda-emc/spack-stack/stack/cmd/stack_cmds/create.py @@ -48,6 +48,8 @@ def template_help(): def container_config_help(): _, _, container_configs = next(os.walk(stack_path("configs", "containers"))) + # Exclude files like "README.md" + container_configs = [x for x in container_configs if x.endswith(".yaml")] help_string = "Pre-configured container." + os.linesep help_string += "Available options are: " + os.linesep for config in container_configs: @@ -55,40 +57,74 @@ def container_config_help(): return help_string +def container_specs_help(): + _, _, specs_lists = next(os.walk(stack_path("configs", "containers", "specs"))) + help_string = "List of specs to build in container." + os.linesep + help_string += "Available options are: " + os.linesep + for specs_list in specs_lists: + help_string += "\t" + specs_list.rstrip(".yaml") + os.linesep + return help_string + + def setup_common_parser_args(subparser): """Shared CLI args for container and environment subcommands""" + subparser.add_argument( - "--template", - type=str, + "--overwrite", + action="store_true", required=False, - dest="template", - default="empty", - help=template_help(), + default=False, + help="Overwrite existing environment if it exists." " Warning this is dangerous.", ) + +def setup_ctr_parser(subparser): + """create container-specific parsing options""" + + subparser.add_argument("--container", required=True, help=container_config_help()) + + subparser.add_argument("--specs", required=True, help=container_specs_help()) + subparser.add_argument( - "--name", + "--dir", type=str, required=False, - default=None, - help='Environment name, defaults to "{}".'.format(default_env_name), + default=default_env_path, + help="Environment will be placed in /container/." + " Default is {}/container/.".format(default_env_path), ) + setup_common_parser_args(subparser) + + +def setup_env_parser(subparser): + """create environment-specific parsing options""" + setup_common_parser_args(subparser) + subparser.add_argument( "--dir", type=str, required=False, default=default_env_path, - help="Environment will be placed in //." - " Default is {}//.".format(default_env_path), + help="Environment will be placed in //." + " Default is {}//.".format(default_env_path), ) subparser.add_argument( - "--overwrite", - action="store_true", + "--name", + type=str, required=False, - default=False, - help="Overwrite existing environment if it exists." " Warning this is dangerous.", + default=None, + help="Environment name, defaults to