forked from MakazhanAlpamys/Soup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtui.py
More file actions
52 lines (42 loc) · 1.48 KB
/
Copy pathtui.py
File metadata and controls
52 lines (42 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""soup tui — full-screen Textual dashboard for live + historical runs.
The Textual app itself is constructed inside ``run_tui`` so the import is
lazy and the rest of the CLI keeps working when ``textual`` isn't
installed. The user-facing error mirrors the pattern used by ``soup ui``
and the optional ``[tui]`` install extra.
"""
from __future__ import annotations
import typer
from rich.console import Console
console = Console()
def _missing_dep_panel() -> str:
return (
"[red]Textual is not installed.[/]\n\n"
"[bold]Install:[/] pip install \"soup-cli\\[tui]\"\n"
"[dim]Or directly:[/] pip install textual"
)
def tui(
refresh: float = typer.Option(
1.0,
"--refresh",
help="Refresh interval in seconds (0.25 - 10.0).",
),
limit: int = typer.Option(
50,
"--limit",
help="Maximum runs to load into the dashboard.",
),
):
"""Full-screen terminal dashboard: list runs, inspect metrics, tail logs."""
if refresh < 0.25 or refresh > 10.0:
console.print("[red]--refresh must be between 0.25 and 10.0[/]")
raise typer.Exit(2)
if limit < 1 or limit > 1000:
console.print("[red]--limit must be between 1 and 1000[/]")
raise typer.Exit(2)
try:
from soup_cli.tui_app import SoupTuiApp
except ImportError:
console.print(_missing_dep_panel())
raise typer.Exit(1) from None
app = SoupTuiApp(refresh_secs=refresh, run_limit=limit)
app.run()