Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Added cli function to module and refactored #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

slegge
Copy link
Contributor

@slegge slegge commented Apr 21, 2023

I was fiddling around with the code, trying to break things up into smaller chunks to make it easier to modify. While I was at it, I added a cli to the module

$ python3 -m baseball
usage: baseball [-h] {schedule,site-generate} ...

$ python3 -m baseball schedule -h
usage: baseball schedule [-h] [--start-date [YYYY-MM-DD]]
[--end-date [YYYY-MM-DD]]

optional arguments:
-h, --help show this help message and exit
--start-date [YYYY-MM-DD]
start or only date to retrieve games for
--end-date [YYYY-MM-DD]
end date to retrieve games for, if not set will be the
same as start-date

Copyright (c) 2018-2023 Benjamin B. Crom - MIT License

$ python3 -m baseball schedule --start-date 2023-04-20 --end-date 2023-04-20
ScheduleSummaryGame(gamePk=718497, officialDate="2023-04-20", description="Boston Red Sox vs. Minnesota Twins", status="Final")
ScheduleSummaryGame(gamePk=718496, officialDate="2023-04-20", description="New York Yankees vs. Los Angeles Angels", status="Final")
ScheduleSummaryGame(gamePk=718500, officialDate="2023-04-20", description="Pittsburgh Pirates vs. Cincinnati Reds", status="In Progress")
ScheduleSummaryGame(gamePk=718498, officialDate="2023-04-20", description="Philadelphia Phillies vs. Colorado Rockies", status="In Progress")
ScheduleSummaryGame(gamePk=718499, officialDate="2023-04-20", description="Chicago Cubs vs. Los Angeles Dodgers", status="Delayed Start: Rain")
ScheduleSummaryGame(gamePk=718494, officialDate="2023-04-20", description="Arizona Diamondbacks vs. San Diego Padres", status="Pre-Game")
ScheduleSummaryGame(gamePk=718503, officialDate="2023-04-20", description="San Francisco Giants vs. New York Mets", status="Pre-Game")

$ python3 -m baseball site-generate --output-dir output_dir/files --write-game-html --write-date-html --write-index-html
Generating livebaseballscorecards files in output_dir/files

$ ll output_dir/files/
total 1.3M
drwxr-xr-x. 2 root root 4.0K Apr 21 00:05 .
drwxr-xr-x. 3 root root 4.0K Apr 21 00:05 ..
-rw-r--r--. 1 root root 1.8K Apr 21 00:05 2023-04-20-CIN-PIT-1.html
-rw-r--r--. 1 root root 198K Apr 21 00:05 2023-04-20-CIN-PIT-1.svg
-rw-r--r--. 1 root root 1.8K Apr 21 00:05 2023-04-20-COL-PHI-1.html
-rw-r--r--. 1 root root 175K Apr 21 00:05 2023-04-20-COL-PHI-1.svg
-rw-r--r--. 1 root root 1.8K Apr 21 00:05 2023-04-20-LAA-NYY-1.html
-rw-r--r--. 1 root root 321K Apr 21 00:05 2023-04-20-LAA-NYY-1.svg
-rw-r--r--. 1 root root 1.8K Apr 21 00:05 2023-04-20-LAD-CHC-1.html
-rw-r--r--. 1 root root 47K Apr 21 00:05 2023-04-20-LAD-CHC-1.svg
-rw-r--r--. 1 root root 1.8K Apr 21 00:05 2023-04-20-MIN-BOS-1.html
-rw-r--r--. 1 root root 321K Apr 21 00:05 2023-04-20-MIN-BOS-1.svg
-rw-r--r--. 1 root root 1.8K Apr 21 00:05 2023-04-20-NYM-SF-1.html
-rw-r--r--. 1 root root 47K Apr 21 00:05 2023-04-20-NYM-SF-1.svg
-rw-r--r--. 1 root root 1.8K Apr 21 00:05 2023-04-20-SD-AZ-1.html
-rw-r--r--. 1 root root 47K Apr 21 00:05 2023-04-20-SD-AZ-1.svg
-rw-r--r--. 1 root root 13K Apr 21 00:05 2023-04-20.html
-rw-r--r--. 1 root root 13K Apr 21 00:05 index.html

@benjamincrom
Copy link
Owner

Hey! Sorry, I totally missed this PR last year. Do you mind bringing it up-to-date with the main branch? It looks really useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants