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:
@@ -158,13 +158,13 @@ def prompt_checklist(title: str, items: list, pre_selected: list = None) -> list
|
||||
pre_selected = []
|
||||
|
||||
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()
|
||||
|
||||
try:
|
||||
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
|
||||
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(
|
||||
menu_items,
|
||||
multi_select=True,
|
||||
show_multi_select_hint=True,
|
||||
show_multi_select_hint=False,
|
||||
multi_select_cursor="[✓] ",
|
||||
multi_select_select_on_accept=False,
|
||||
multi_select_empty_ok=True,
|
||||
@@ -187,12 +187,9 @@ def prompt_checklist(title: str, items: list, pre_selected: list = None) -> list
|
||||
terminal_menu.show()
|
||||
|
||||
if terminal_menu.chosen_menu_entries is None:
|
||||
# User pressed Escape
|
||||
return []
|
||||
|
||||
# Filter out the "Continue →" entry and return original indices
|
||||
continue_idx = len(items)
|
||||
selected = [i for i in terminal_menu.chosen_menu_indices if i != continue_idx]
|
||||
selected = list(terminal_menu.chosen_menu_indices or [])
|
||||
return selected
|
||||
|
||||
except ImportError:
|
||||
@@ -203,16 +200,13 @@ def prompt_checklist(title: str, items: list, pre_selected: list = None) -> list
|
||||
for i, item in enumerate(items):
|
||||
marker = color("[✓]", Colors.GREEN) if i in selected else "[ ]"
|
||||
print(f" {marker} {i + 1}. {item}")
|
||||
print(f" {len(items) + 1}. {color('Continue →', Colors.GREEN)}")
|
||||
print()
|
||||
|
||||
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:
|
||||
break
|
||||
idx = int(value) - 1
|
||||
if idx == len(items):
|
||||
break
|
||||
if 0 <= idx < len(items):
|
||||
if idx in selected:
|
||||
selected.discard(idx)
|
||||
|
||||
@@ -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]:
|
||||
"""Multi-select checklist of toolsets. Returns set of selected toolset keys."""
|
||||
title = color(f"Tools for {platform_label}", Colors.YELLOW)
|
||||
hint = color(" Press SPACE to toggle, ENTER on Continue when done.", Colors.DIM)
|
||||
print(title)
|
||||
print(hint)
|
||||
print(color(f"Tools for {platform_label}", Colors.YELLOW))
|
||||
print(color(" SPACE to toggle, ENTER to confirm.", Colors.DIM))
|
||||
print()
|
||||
|
||||
labels = []
|
||||
@@ -152,7 +150,7 @@ def _prompt_toolset_checklist(platform_label: str, enabled: Set[str]) -> Set[str
|
||||
try:
|
||||
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)]
|
||||
|
||||
menu = TerminalMenu(
|
||||
@@ -173,10 +171,9 @@ def _prompt_toolset_checklist(platform_label: str, enabled: Set[str]) -> Set[str
|
||||
menu.show()
|
||||
|
||||
if menu.chosen_menu_entries is None:
|
||||
return enabled # Escape pressed, keep current
|
||||
return enabled
|
||||
|
||||
continue_idx = len(CONFIGURABLE_TOOLSETS)
|
||||
selected_indices = [i for i in (menu.chosen_menu_indices or []) if i != continue_idx]
|
||||
selected_indices = list(menu.chosen_menu_indices or [])
|
||||
|
||||
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):
|
||||
marker = color("[✓]", Colors.GREEN) if i in selected else "[ ]"
|
||||
print(f" {marker} {i + 1}. {label}")
|
||||
print(f" {len(labels) + 1}. {color('Continue →', Colors.GREEN)}")
|
||||
print()
|
||||
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:
|
||||
break
|
||||
idx = int(val) - 1
|
||||
if idx == len(labels):
|
||||
break
|
||||
if 0 <= idx < len(labels):
|
||||
if idx in selected:
|
||||
selected.discard(idx)
|
||||
|
||||
Reference in New Issue
Block a user