From 4cbe592e0a0fae13f0a89918a66fd983dd84464f Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Wed, 15 Apr 2026 22:28:45 -0500 Subject: feat: add Textual TUI with auto-refresh, leaders, playoff picture, and box score MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduces an interactive terminal UI via the `--tui` flag backed by the Textual framework. Scores and standings auto-refresh on a configurable interval (default 60s, minimum 10s) using asyncio with nba_api calls offloaded to a thread pool to keep the event loop unblocked. New tabs: - Scores / Standings (existing views, now live-updating) - Leaders: top-25 by stat category, cycle with < / > keys - Playoff Picture: conference seeding with clinch/elimination status - Box Score: per-player live stats, load any game with keys 1–9 Refactored scores.py and standings.py to separate rendering from I/O (get_scoreboard_table, get_east/west_standings_table), keeping the existing static CLI path fully intact. Added -sc / -st shortcut flags. Adds textual>=0.89.1,<7.0 dependency, build-system declaration for uv, and package-data entry for the bundled .tcss stylesheet. --- nba/cli.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'nba/cli.py') diff --git a/nba/cli.py b/nba/cli.py index 82c3883..e5f460d 100644 --- a/nba/cli.py +++ b/nba/cli.py @@ -13,12 +13,33 @@ def nba() -> None: Parse command-line arguments and display either scoreboard or standings. """ parser = argparse.ArgumentParser(description="NBA Scoreboard and Standings") - parser.add_argument("--scores", action="store_true", help="Display the scoreboard") parser.add_argument( - "--standings", action="store_true", help="Display the standings" + "--scores", "-sc", action="store_true", help="Display the scoreboard" + ) + parser.add_argument( + "--standings", "-st", action="store_true", help="Display the standings" + ) + parser.add_argument( + "--tui", action="store_true", help="Launch the interactive TUI" + ) + parser.add_argument( + "--refresh", + type=int, + default=60, + metavar="SECONDS", + help="Auto-refresh interval in TUI mode (default: 60, minimum: 10)", ) args = parser.parse_args() + if args.tui: + from nba.tui.app import NBAApp + + initial_tab = "standings" if args.standings else "scores" + refresh_interval = max(args.refresh, 10) + NBAApp(initial_tab=initial_tab, refresh_interval=refresh_interval).run() + return + + # Legacy static mode games, ranks = fetch_data.fetch_data() if args.scores: @@ -26,4 +47,4 @@ def nba() -> None: elif args.standings: standings.build_standings(ranks) else: - print("Please specify --scores or --standings") + print("Please specify --scores or --standings (or use --tui for interactive mode)") -- cgit v1.2.3