krz/nba-scores
A CLI/TUI app for NBA scores.
clone: git clone https://gitbay.org/krz/nba-scores.git
1"""
2This script uses argparse to parse command line arguments.
3
4It imports the required modules and sets up a parser with basic options for demonstration purposes.
5"""
6
7import argparse
8
9from nba import fetch_data, scores, standings
10
11
12def nba() -> None:
13 """
14 Parse command-line arguments and display either scoreboard or standings.
15 """
16 parser = argparse.ArgumentParser(description="NBA Scoreboard and Standings")
17 parser.add_argument(
18 "--scores", "-sc", action="store_true", help="Display the scoreboard"
19 )
20 parser.add_argument(
21 "--standings", "-st", action="store_true", help="Display the standings"
22 )
23 parser.add_argument("--tui", action="store_true", help="Launch the interactive TUI")
24 parser.add_argument(
25 "--refresh",
26 type=int,
27 default=60,
28 metavar="SECONDS",
29 help="Auto-refresh interval in TUI mode (default: 60, minimum: 10)",
30 )
31 args = parser.parse_args()
32
33 if args.tui:
34 from nba.tui.app import NBAApp
35
36 initial_tab = "standings" if args.standings else "scores"
37 refresh_interval = max(args.refresh, 10)
38 NBAApp(initial_tab=initial_tab, refresh_interval=refresh_interval).run()
39 return
40
41 # Legacy static mode
42 games, ranks = fetch_data.fetch_data()
43
44 if args.scores:
45 scores.build_scoreboard(games, ranks)
46 elif args.standings:
47 standings.build_standings(ranks)
48 else:
49 print(
50 "Please specify --scores or --standings (or use --tui for interactive mode)"
51 )