Het Satasiya | c34b3ea | 2022-02-06 17:28:49 -0800 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | // To run the demo, ensure that you have a file named scouting_config.json at the workspace root with your TBA api key in it. |
| 4 | import ( |
Philipp Schrader | d3fac19 | 2022-03-02 20:35:46 -0800 | [diff] [blame] | 5 | "encoding/json" |
| 6 | "flag" |
| 7 | "fmt" |
Het Satasiya | c34b3ea | 2022-02-06 17:28:49 -0800 | [diff] [blame] | 8 | "log" |
| 9 | |
| 10 | "github.com/davecgh/go-spew/spew" |
| 11 | "github.com/frc971/971-Robot-Code/scouting/scraping" |
| 12 | ) |
| 13 | |
| 14 | func main() { |
Philipp Schrader | d3fac19 | 2022-03-02 20:35:46 -0800 | [diff] [blame] | 15 | jsonPtr := flag.Bool("json", false, "If set, dump as JSON, rather than Go debug output.") |
| 16 | flag.Parse() |
| 17 | |
Het Satasiya | c34b3ea | 2022-02-06 17:28:49 -0800 | [diff] [blame] | 18 | // Get all the matches. |
Philipp Schrader | d3fac19 | 2022-03-02 20:35:46 -0800 | [diff] [blame] | 19 | matches, err := scraping.AllMatches(2016, "nytr", "") |
Het Satasiya | c34b3ea | 2022-02-06 17:28:49 -0800 | [diff] [blame] | 20 | if err != nil { |
Philipp Schrader | d3fac19 | 2022-03-02 20:35:46 -0800 | [diff] [blame] | 21 | log.Fatal("Failed to scrape match list: ", err) |
Het Satasiya | c34b3ea | 2022-02-06 17:28:49 -0800 | [diff] [blame] | 22 | } |
Philipp Schrader | d3fac19 | 2022-03-02 20:35:46 -0800 | [diff] [blame] | 23 | |
Het Satasiya | c34b3ea | 2022-02-06 17:28:49 -0800 | [diff] [blame] | 24 | // Dump the matches. |
Philipp Schrader | d3fac19 | 2022-03-02 20:35:46 -0800 | [diff] [blame] | 25 | if *jsonPtr { |
| 26 | jsonData, err := json.MarshalIndent(matches, "", " ") |
| 27 | if err != nil { |
| 28 | log.Fatal("Failed to turn match list into JSON: ", err) |
| 29 | } |
| 30 | fmt.Println(string(jsonData)) |
| 31 | } else { |
| 32 | spew.Dump(matches) |
| 33 | } |
Het Satasiya | c34b3ea | 2022-02-06 17:28:49 -0800 | [diff] [blame] | 34 | } |