-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (43 loc) · 1.21 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"flag"
"log"
"os"
)
var minAppearances, maxAppearances = 0, 5000
var addressFilePath string
var reuseDatabaseFile string
var dataDir string
var format string
func init() {
// Parse command line options
flag.StringVar(&reuseDatabaseFile, "reuse", "", "reuse database")
flag.StringVar(&dataDir, "datadir", "", "directory to save the database to")
flag.StringVar(&format, "format", "txt", "output format: csv (machine readable) or txt (human readable)")
flag.Parse()
addressFilePath = flag.Arg(0)
}
func main() {
// First we set everything up: we connect to the database and detect available providers
// (based on API keys stored in trueBlocks.toml file)
comparison := Setup(addressFilePath, dataDir, reuseDatabaseFile)
// If we aren't using an existing database, we will download data from the providers
if reuseDatabaseFile == "" {
if err := comparison.DownloadAppearances(); err != nil {
log.Fatalln(err)
}
} else {
log.Println("Using existing database, will not download data")
}
// Load the results
results, err := comparison.Results()
if err != nil {
log.Fatalln(err)
}
// Print the report
if format == "csv" {
_ = results.Csv(os.Stdout)
} else {
results.Text()
}
}