fix(setup): handle TerminalMenu init failures with safe fallback

This commit is contained in:
Josh Black-Star 2026-03-02 00:52:27 -08:00
parent 719f2eef32
commit b1bf11b0fe
No known key found for this signature in database

View file

@ -100,28 +100,32 @@ def prompt_choice(question: str, choices: list, default: int = 0) -> int:
return idx return idx
except (ImportError, NotImplementedError): except (ImportError, NotImplementedError):
# Fallback to number-based selection (simple_term_menu doesn't support Windows) pass
for i, choice in enumerate(choices): except Exception as e:
marker = "" if i == default else "" print(f" (Interactive menu unavailable: {e})")
if i == default:
print(color(f" {marker} {choice}", Colors.GREEN)) # Fallback to number-based selection (simple_term_menu doesn't support Windows)
else: for i, choice in enumerate(choices):
print(f" {marker} {choice}") marker = "" if i == default else ""
if i == default:
while True: print(color(f" {marker} {choice}", Colors.GREEN))
try: else:
value = input(color(f" Select [1-{len(choices)}] ({default + 1}): ", Colors.DIM)) print(f" {marker} {choice}")
if not value:
return default while True:
idx = int(value) - 1 try:
if 0 <= idx < len(choices): value = input(color(f" Select [1-{len(choices)}] ({default + 1}): ", Colors.DIM))
return idx if not value:
print_error(f"Please enter a number between 1 and {len(choices)}") return default
except ValueError: idx = int(value) - 1
print_error("Please enter a number") if 0 <= idx < len(choices):
except (KeyboardInterrupt, EOFError): return idx
print() print_error(f"Please enter a number between 1 and {len(choices)}")
sys.exit(1) except ValueError:
print_error("Please enter a number")
except (KeyboardInterrupt, EOFError):
print()
sys.exit(1)
def prompt_yes_no(question: str, default: bool = True) -> bool: def prompt_yes_no(question: str, default: bool = True) -> bool:
"""Prompt for yes/no.""" """Prompt for yes/no."""