diff --git a/latch_cli/services/init/init.py b/latch_cli/services/init/init.py index 7429523e..568cfa5d 100644 --- a/latch_cli/services/init/init.py +++ b/latch_cli/services/init/init.py @@ -3,6 +3,7 @@ import re import shutil import subprocess +import sys from pathlib import Path from typing import Callable, Optional @@ -330,18 +331,29 @@ def init( ) if template is None: - template_func = select_tui( + template_choice = select_tui( title="Select Workflow Template", options=[ - {"display_name": name, "value": fn} for name, fn in option_map.items() + {"display_name": name, "value": (name, fn)} + for name, fn in option_map.items() ], ) + elif template in template_flag_to_option.keys(): + choice = template_flag_to_option[template] + template_choice = (choice, option_map[choice]) else: - template_func = option_map[template_flag_to_option[template]] + click.secho( + f"Invalid template choice: {template} - valid choices:" + f" {list(template_flag_to_option.keys())}", + fg="red", + ) + raise click.exceptions.Exit(1) - if template_func is None: + if template_choice is None: return False + (chosen_template, template_func) = template_choice + try: pkg_root.mkdir(parents=True) except FileExistsError: @@ -359,7 +371,7 @@ def init( base_image_type = BaseImageOptions[base_image_type_str] - if template_func == "Empty workflow": + if chosen_template == "Empty workflow": base_image_type = select_tui( title="Select the base docker image to use for the workflow", options=[