blob: 0ea3e53152275f23cbdf5cea356c637e8ac113c4 [file] [log] [blame]
Het Satasiyac34b3ea2022-02-06 17:28:49 -08001package 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.
4import (
Philipp Schraderd3fac192022-03-02 20:35:46 -08005 "encoding/json"
6 "flag"
7 "fmt"
Het Satasiyac34b3ea2022-02-06 17:28:49 -08008 "log"
9
10 "github.com/davecgh/go-spew/spew"
11 "github.com/frc971/971-Robot-Code/scouting/scraping"
12)
13
14func main() {
Philipp Schraderd3fac192022-03-02 20:35:46 -080015 jsonPtr := flag.Bool("json", false, "If set, dump as JSON, rather than Go debug output.")
16 flag.Parse()
17
Het Satasiyac34b3ea2022-02-06 17:28:49 -080018 // Get all the matches.
Philipp Schraderd3fac192022-03-02 20:35:46 -080019 matches, err := scraping.AllMatches(2016, "nytr", "")
Het Satasiyac34b3ea2022-02-06 17:28:49 -080020 if err != nil {
Philipp Schraderd3fac192022-03-02 20:35:46 -080021 log.Fatal("Failed to scrape match list: ", err)
Het Satasiyac34b3ea2022-02-06 17:28:49 -080022 }
Philipp Schraderd3fac192022-03-02 20:35:46 -080023
Het Satasiyac34b3ea2022-02-06 17:28:49 -080024 // Dump the matches.
Philipp Schraderd3fac192022-03-02 20:35:46 -080025 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 Satasiyac34b3ea2022-02-06 17:28:49 -080034}