-
Notifications
You must be signed in to change notification settings - Fork 0
/
pickem.go
56 lines (50 loc) · 1.62 KB
/
pickem.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
53
54
55
56
package main
import (
"context"
fs "cloud.google.com/go/firestore"
"github.com/reallyasi9/b1gpickem/internal/tools/pickem"
)
type pickemCmd struct {
DryRun bool `help:"Print database writes to log and exit without writing."`
Force bool `help:"Force overwrite or delete data from datastore."`
Season int `arg:"" help:"Season of slate." required:""`
Week int `arg:"" help:"Week of slate." required:""`
Picker string `arg:"" help:"Picker." required:""`
Picks []string `arg:"" help:"Names of teams to pick."`
SuperDog string `help:"Superdog pick."`
}
func (a *pickemCmd) Run(g *globalCmd) error {
ctx := pickem.NewContext(context.Background())
ctx.DryRun = a.DryRun
ctx.Force = a.Force
var err error
ctx.FirestoreClient, err = fs.NewClient(ctx.Context, g.ProjectID)
if err != nil {
return err
}
ctx.Season = a.Season
ctx.Week = a.Week
ctx.Picker = a.Picker
ctx.Picks = a.Picks
ctx.SuperDog = a.SuperDog
return pickem.Pickem(ctx)
}
type exportPicksCmd struct {
Season int `arg:"" help:"Season of slate." required:""`
Week int `arg:"" help:"Week of slate." required:""`
Picker string `arg:"" help:"Picker." required:""`
Output string `help:"Output path. Can be a local path or a Google Storage path prefixed by 'gs://'. Default: print to stdout."`
}
func (a *exportPicksCmd) Run(g *globalCmd) error {
ctx := pickem.NewContext(context.Background())
var err error
ctx.FirestoreClient, err = fs.NewClient(ctx.Context, g.ProjectID)
if err != nil {
return err
}
ctx.Season = a.Season
ctx.Week = a.Week
ctx.Picker = a.Picker
ctx.Output = a.Output
return pickem.ExportPicks(ctx)
}