baseball/main.py

41 lines
1009 B
Python

from dotenv import load_dotenv
from rich.console import Console
import argparse
from data import get_game_data
from game import game_factory
from output import output_game
load_dotenv()
console = Console()
def init_games():
games = []
events = get_game_data()
for event in events:
games.append(game_factory(event["competitions"][0]))
return games
# Parse options for teams
def main():
arg_parser = argparse.ArgumentParser(prog="Baseball Score CLI",
description="Get the current scores of the games.")
arg_parser.add_argument('-t', '--team',
help="Give a specific team to get scores for.",
required=False)
args = arg_parser.parse_args()
if args.team:
# find the team
print(args.team)
else:
for event in init_games():
table = output_game(event)
console.print(table)
if __name__ == "__main__":
main()