-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd_fetch-builds.go
52 lines (44 loc) · 1.07 KB
/
cmd_fetch-builds.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 (
"github.com/anaminus/rbxark/fetch"
"github.com/jessevdk/go-flags"
)
func init() {
OptionTags{
"workers": &flags.Option{
Description: "The number of worker threads used when downloading files.",
Default: []string{"32"},
},
}.AddTo(FlagParser.AddCommand(
"fetch-builds",
"Discover new builds from each server.",
`Downloads and scans the DeployHistory file from each server in the
database. Any found builds that are new are inserted into the
database.`,
&CmdFetchBuilds{},
))
}
type CmdFetchBuilds struct {
Workers int `long:"workers"`
}
func (cmd *CmdFetchBuilds) Execute(args []string) error {
db, cfgdir, err := OpenDatabase(args)
if err != nil {
return err
}
defer db.Close()
config, err := LoadConfig(cfgdir)
if err != nil {
return err
}
action := Action{Context: Main}
if err := action.Init(db); err != nil {
return err
}
fetcher := fetch.NewFetcher(nil, cmd.Workers, config.RateLimit)
file := config.DeployHistory
if file == "" {
file = "DeployHistory.txt"
}
return action.FetchBuilds(db, fetcher, file)
}