diff options
| author | Christian Cleberg <[email protected]> | 2026-04-15 22:37:06 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-15 22:37:06 -0500 |
| commit | 4d40494f3e9aade0f5302678e4df67a7613c157b (patch) | |
| tree | c12b55772f72c0221aacb8d4801bde309c46f8c6 /build/lib/nba/cli.py | |
| parent | b542a36c072c353e9f3ba23c0fec99e55da8289a (diff) | |
| download | nba-scores-4d40494f3e9aade0f5302678e4df67a7613c157b.tar.gz nba-scores-4d40494f3e9aade0f5302678e4df67a7613c157b.tar.bz2 nba-scores-4d40494f3e9aade0f5302678e4df67a7613c157b.zip | |
update README
Diffstat (limited to 'build/lib/nba/cli.py')
| -rw-r--r-- | build/lib/nba/cli.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/build/lib/nba/cli.py b/build/lib/nba/cli.py new file mode 100644 index 0000000..e5f460d --- /dev/null +++ b/build/lib/nba/cli.py @@ -0,0 +1,50 @@ +""" +This script uses argparse to parse command line arguments. + +It imports the required modules and sets up a parser with basic options for demonstration purposes. +""" + +import argparse +from nba import fetch_data, scores, standings + + +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", "-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: + scores.build_scoreboard(games, ranks) + elif args.standings: + standings.build_standings(ranks) + else: + print("Please specify --scores or --standings (or use --tui for interactive mode)") |
