Skip to content

Commit

Permalink
Making API key a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
fortinj1354 committed Jan 26, 2019
1 parent 22fd301 commit 2d0c8c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Adds a blank column after each team number to assign a team member to scout the

Get the schedule for an event:

`TBAMatchScheduleDownload.exe -event 2019gadal`
`TBAMatchScheduleDownload.exe -event 2019gadal -key someapikey`

Get the schedule for an event and filter for a specific team number:

`TBAMatchScheduleDownload.exe -event 2019gadal -team 2974`
`TBAMatchScheduleDownload.exe -event 2019gadal -team 2974 -key someapikey`

View help:

Expand All @@ -21,6 +21,9 @@ If there is no event schedule available the resulting CSV file will be empty.

## Command Line Arguments

- key (required)
- API key for The Blue Alliance Read API v3
- https://www.thebluealliance.com/apidocs
- event (required)
- Event code from The Blue Alliance.
- Example: For https://www.thebluealliance.com/event/2019gadal the event code is 2019gadal
Expand Down
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ import (
)

func main() {
var apiKey = flag.String("key", "", "API key for The Blue Alliance Read API v3, available at https://www.thebluealliance.com/apidocs")
var eventCode = flag.String("event", "", "Event code from The Blue Alliance.\nExample: For https://www.thebluealliance.com/event/2019gadal the event code is 2019gadal")
var filterTeam = flag.String("team", "", "Filter the schedule for a specific team number\nExample: 2974")
flag.Parse()

if *eventCode != "" {
apiKey := "U9EN25M8zVayHwPHWZxSS6a1U3lRD8s3EByAadpK5jHpJJCdMl4F2NDOVrN57uxn"

matches := makeTBARequest(*eventCode, *filterTeam, apiKey)
if *apiKey == "" {
print("API key is required, pass it in with the -key flag")
} else if *eventCode == "" {
print("Event code is required, pass it in with the -event flag")
} else {
matches := makeTBARequest(*eventCode, *filterTeam, *apiKey)
if matches != nil {
fileName := writeToCSV(&matches, *eventCode, *filterTeam)

print("Results available in " + fileName)
}
} else {
print("Event code is required, pass it in with the -event flag")
}
}

Expand Down

0 comments on commit 2d0c8c4

Please sign in to comment.