|
8 | 8 |
|
9 | 9 | from dotenv import load_dotenv, find_dotenv |
10 | 10 | from rich.console import Console |
| 11 | +from rich.panel import Panel |
11 | 12 | from rich.table import Table |
12 | 13 |
|
13 | | -from . import flow, lib, setting, query |
| 14 | +from . import flow, lib, setting |
14 | 15 | from .setup import sync_setup, drop_setup, flow_names_with_setup, apply_setup_changes |
15 | 16 |
|
16 | 17 | # Create ServerSettings lazily upon first call, as environment variables may be loaded from files, etc. |
@@ -521,9 +522,29 @@ def _flow_name(name: str | None) -> str: |
521 | 522 | elif len(names) == 1: |
522 | 523 | return names[0] |
523 | 524 | else: |
524 | | - raise click.UsageError( |
525 | | - f"Multiple flows available, please specify which flow to target by appending :FlowName to the APP_TARGET.\nAvailable: {available}" |
526 | | - ) |
| 525 | + console = Console() |
| 526 | + index = 0 |
| 527 | + |
| 528 | + while True: |
| 529 | + console.clear() |
| 530 | + console.print( |
| 531 | + Panel.fit("Select a Flow", title_align="left", border_style="cyan") |
| 532 | + ) |
| 533 | + for i, fname in enumerate(names): |
| 534 | + console.print( |
| 535 | + f"> [bold green]{fname}[/bold green]" |
| 536 | + if i == index |
| 537 | + else f" {fname}" |
| 538 | + ) |
| 539 | + |
| 540 | + key = click.getchar() |
| 541 | + if key == "\x1b[A": # Up arrow |
| 542 | + index = (index - 1) % len(names) |
| 543 | + elif key == "\x1b[B": # Down arrow |
| 544 | + index = (index + 1) % len(names) |
| 545 | + elif key in ("\r", "\n"): # Enter |
| 546 | + console.clear() |
| 547 | + return names[index] |
527 | 548 |
|
528 | 549 |
|
529 | 550 | def _flow_by_name(name: str | None) -> flow.Flow: |
|
0 commit comments