MCPcopy Index your code
hub / github.com/github/spec-kit / run_selection_loop

Function run_selection_loop

src/specify_cli/_console.py:198–220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

196 console.print()
197
198 def run_selection_loop():
199 nonlocal selected_key, selected_index
200 _transient = sys.platform != "win32"
201 with Live(create_selection_panel(), console=console, transient=_transient, auto_refresh=False) as live:
202 while True:
203 try:
204 key = get_key()
205 if key == 'up':
206 selected_index = (selected_index - 1) % len(option_keys)
207 elif key == 'down':
208 selected_index = (selected_index + 1) % len(option_keys)
209 elif key == 'enter':
210 selected_key = option_keys[selected_index]
211 break
212 elif key == 'escape':
213 console.print("\n[yellow]Selection cancelled[/yellow]")
214 raise typer.Exit(code=1)
215
216 live.update(create_selection_panel(), refresh=True)
217
218 except KeyboardInterrupt:
219 console.print("\n[yellow]Selection cancelled[/yellow]")
220 raise typer.Exit(code=1)
221
222 run_selection_loop()
223

Callers 1

select_with_arrowsFunction · 0.85

Calls 4

create_selection_panelFunction · 0.85
get_keyFunction · 0.85
printMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected