refactor: clarify user prompts in checklist interfaces

- Updated messaging in the checklist prompts to simplify instructions for item selection, changing "Press SPACE to select items, then ENTER on Continue" to "SPACE to toggle, ENTER to confirm."
- Removed the "Continue →" entry from the menu items to streamline the selection process.
- Enhanced user experience by clarifying input prompts and removing unnecessary options, ensuring a more intuitive interaction.
This commit is contained in:
Teknium 2026-02-23 23:57:31 +00:00
parent d802db4de0
commit 7a6d4666a2
2 changed files with 11 additions and 23 deletions

View file

@ -158,13 +158,13 @@ def prompt_checklist(title: str, items: list, pre_selected: list = None) -> list
pre_selected = [] pre_selected = []
print(color(title, Colors.YELLOW)) print(color(title, Colors.YELLOW))
print_info("Press SPACE to select items, then ENTER on Continue.") print_info("SPACE to toggle, ENTER to confirm.")
print() print()
try: try:
from simple_term_menu import TerminalMenu from simple_term_menu import TerminalMenu
menu_items = [f" {item}" for item in items] + [" Continue →"] menu_items = [f" {item}" for item in items]
# Map pre-selected indices to the actual menu entry strings # Map pre-selected indices to the actual menu entry strings
preselected = [menu_items[i] for i in pre_selected if i < len(menu_items)] preselected = [menu_items[i] for i in pre_selected if i < len(menu_items)]
@ -172,7 +172,7 @@ def prompt_checklist(title: str, items: list, pre_selected: list = None) -> list
terminal_menu = TerminalMenu( terminal_menu = TerminalMenu(
menu_items, menu_items,
multi_select=True, multi_select=True,
show_multi_select_hint=True, show_multi_select_hint=False,
multi_select_cursor="[✓] ", multi_select_cursor="[✓] ",
multi_select_select_on_accept=False, multi_select_select_on_accept=False,
multi_select_empty_ok=True, multi_select_empty_ok=True,
@ -187,12 +187,9 @@ def prompt_checklist(title: str, items: list, pre_selected: list = None) -> list
terminal_menu.show() terminal_menu.show()
if terminal_menu.chosen_menu_entries is None: if terminal_menu.chosen_menu_entries is None:
# User pressed Escape
return [] return []
# Filter out the "Continue →" entry and return original indices selected = list(terminal_menu.chosen_menu_indices or [])
continue_idx = len(items)
selected = [i for i in terminal_menu.chosen_menu_indices if i != continue_idx]
return selected return selected
except ImportError: except ImportError:
@ -203,16 +200,13 @@ def prompt_checklist(title: str, items: list, pre_selected: list = None) -> list
for i, item in enumerate(items): for i, item in enumerate(items):
marker = color("[✓]", Colors.GREEN) if i in selected else "[ ]" marker = color("[✓]", Colors.GREEN) if i in selected else "[ ]"
print(f" {marker} {i + 1}. {item}") print(f" {marker} {i + 1}. {item}")
print(f" {len(items) + 1}. {color('Continue →', Colors.GREEN)}")
print() print()
try: try:
value = input(color(" Toggle item # (or Enter to continue): ", Colors.DIM)).strip() value = input(color(" Toggle # (or Enter to confirm): ", Colors.DIM)).strip()
if not value: if not value:
break break
idx = int(value) - 1 idx = int(value) - 1
if idx == len(items):
break
if 0 <= idx < len(items): if 0 <= idx < len(items):
if idx in selected: if idx in selected:
selected.discard(idx) selected.discard(idx)

View file

@ -134,10 +134,8 @@ def _prompt_choice(question: str, choices: list, default: int = 0) -> int:
def _prompt_toolset_checklist(platform_label: str, enabled: Set[str]) -> Set[str]: def _prompt_toolset_checklist(platform_label: str, enabled: Set[str]) -> Set[str]:
"""Multi-select checklist of toolsets. Returns set of selected toolset keys.""" """Multi-select checklist of toolsets. Returns set of selected toolset keys."""
title = color(f"Tools for {platform_label}", Colors.YELLOW) print(color(f"Tools for {platform_label}", Colors.YELLOW))
hint = color(" Press SPACE to toggle, ENTER on Continue when done.", Colors.DIM) print(color(" SPACE to toggle, ENTER to confirm.", Colors.DIM))
print(title)
print(hint)
print() print()
labels = [] labels = []
@ -152,7 +150,7 @@ def _prompt_toolset_checklist(platform_label: str, enabled: Set[str]) -> Set[str
try: try:
from simple_term_menu import TerminalMenu from simple_term_menu import TerminalMenu
menu_items = [f" {label}" for label in labels] + [" Continue →"] menu_items = [f" {label}" for label in labels]
preselected = [menu_items[i] for i in pre_selected_indices if i < len(menu_items)] preselected = [menu_items[i] for i in pre_selected_indices if i < len(menu_items)]
menu = TerminalMenu( menu = TerminalMenu(
@ -173,10 +171,9 @@ def _prompt_toolset_checklist(platform_label: str, enabled: Set[str]) -> Set[str
menu.show() menu.show()
if menu.chosen_menu_entries is None: if menu.chosen_menu_entries is None:
return enabled # Escape pressed, keep current return enabled
continue_idx = len(CONFIGURABLE_TOOLSETS) selected_indices = list(menu.chosen_menu_indices or [])
selected_indices = [i for i in (menu.chosen_menu_indices or []) if i != continue_idx]
return {CONFIGURABLE_TOOLSETS[i][0] for i in selected_indices} return {CONFIGURABLE_TOOLSETS[i][0] for i in selected_indices}
@ -187,15 +184,12 @@ def _prompt_toolset_checklist(platform_label: str, enabled: Set[str]) -> Set[str
for i, label in enumerate(labels): for i, label in enumerate(labels):
marker = color("[✓]", Colors.GREEN) if i in selected else "[ ]" marker = color("[✓]", Colors.GREEN) if i in selected else "[ ]"
print(f" {marker} {i + 1}. {label}") print(f" {marker} {i + 1}. {label}")
print(f" {len(labels) + 1}. {color('Continue →', Colors.GREEN)}")
print() print()
try: try:
val = input(color(" Toggle # (or Enter to continue): ", Colors.DIM)).strip() val = input(color(" Toggle # (or Enter to confirm): ", Colors.DIM)).strip()
if not val: if not val:
break break
idx = int(val) - 1 idx = int(val) - 1
if idx == len(labels):
break
if 0 <= idx < len(labels): if 0 <= idx < len(labels):
if idx in selected: if idx in selected:
selected.discard(idx) selected.discard(idx)