/
main.go
93 lines (88 loc) · 1.95 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"os"
"github.com/benfb/vin/commands"
"github.com/urfave/cli/v2"
)
func main() {
app := cli.NewApp()
app.Name = "vin"
app.Usage = "the baseball command-line companion"
app.Version = "0.4.1"
app.Authors = []*cli.Author{
{
Name: "Ben Bailey",
Email: "bennettbailey@gmail.com",
},
}
app.Commands = []*cli.Command{
{
Name: "standings",
Aliases: []string{"s"},
Usage: "Gets the current standings",
ArgsUsage: "[division]",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "aggregate, a",
Usage: "get all standings in one table",
},
},
Action: func(c *cli.Context) error {
division := c.Args().Get(0)
if division == "" && c.Bool("aggregate") {
division = "agg"
} else if division == "" {
division = "all"
}
commands.StandingsCmd(division)
return nil
},
},
{
Name: "results",
Aliases: []string{"r"},
Usage: "Gets results for all the games from a particular day, formatted as mm/dd/yy",
ArgsUsage: "[date]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "team, t",
Value: "all",
Usage: "name of team to get box score for",
},
&cli.StringFlag{
Name: "except, e",
Value: "",
Usage: "name of team to exclude from results",
},
},
Action: func(c *cli.Context) error {
day := c.Args().Get(0)
if day == "" {
day = "today"
}
return commands.ResultsCmd(day, c.String("team"), c.String("except"))
},
},
{
Name: "box",
Aliases: []string{"b"},
Usage: "Get a boxscore for a particular game",
ArgsUsage: "[date]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "team, t",
Value: "all",
Usage: "name of team to get box score for",
},
},
Action: func(c *cli.Context) error {
day := c.Args().Get(0)
if day == "" {
day = "today"
}
return commands.BoxScoreCmd(day, c.String("team"))
},
},
}
app.Run(os.Args)
}