-
Notifications
You must be signed in to change notification settings - Fork 0
/
teams.go
63 lines (57 loc) · 1.95 KB
/
teams.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
57
58
59
60
61
62
63
package main
import (
"context"
fs "cloud.google.com/go/firestore"
"github.com/reallyasi9/b1gpickem/internal/firestore"
"github.com/reallyasi9/b1gpickem/internal/tools/editteams"
)
type editTeamCmd struct {
DryRun bool `help:"Print database writes to log and exit without writing." xor:"Force,DryRun"`
Force bool `help:"Force overwriting or deleting data in database." xor:"Force,DryRun"`
Season int `arg:"" help:"Season where team is defined." required:""`
ID string `arg:"" help:"ID of team to edit." required:""`
Abbreviation string `help:"Team 4-letter abbreviation."`
School string `help:"Team school name."`
Mascot string `help:"Team mascot name."`
ShortName []string `help:"Team short (Luke) name."`
OtherName []string `help:"Team other (model) name."`
Color []string `help:"Team color string."`
Logo []string `help:"Location of team logo."`
Append bool `help:"Append short names, other names, colors, and logos to extant values."`
}
func (a *editTeamCmd) Run(g *globalCmd) error {
ctx := editteams.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.ID = a.ID
ctx.Team = firestore.Team{
Abbreviation: a.Abbreviation,
School: a.School,
Mascot: a.Mascot,
ShortNames: a.ShortName,
OtherNames: a.OtherName,
Colors: a.Color,
Logos: a.Logo,
}
ctx.Append = a.Append
return editteams.EditTeam(ctx)
}
type lsTeamsCmd struct {
Season int `arg:"" help:"Season where team is defined." required:""`
}
func (a *lsTeamsCmd) Run(g *globalCmd) error {
ctx := editteams.NewContext(context.Background())
var err error
ctx.FirestoreClient, err = fs.NewClient(ctx.Context, g.ProjectID)
if err != nil {
return err
}
ctx.Season = a.Season
return editteams.LsTeams(ctx)
}