Feature: Added cli function to module and refactored #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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