-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
70 lines (61 loc) · 1.5 KB
/
commands.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
package main
import (
"github.com/urfave/cli"
"fmt"
"os"
"io/ioutil"
)
var Commands = []cli.Command{
{
Name: "groups",
ShortName: "g",
Usage: "List all groups and teams in the 2018 FIFA World Cup.",
Action: ListGroups,
},
{
Name: "standings",
ShortName: "s",
Usage: "Get current standings for all the groups in the 2018 FIFA World Cup.",
Action: ListStandings,
},
{
Name: "stadiums",
ShortName: "std",
Usage: "Get list of all stadiums to be used in the 2018 FIFA World Cup.",
Action: ListStadiums,
},
{
Name: "teams",
ShortName: "t",
Usage: "Get list of all teams participating in the 2018 FIFA World Cup.",
Action: ListTeams,
},
{
Name: "feed",
ShortName: "f",
Usage: "Get all the feed from the 2018 FIFA World Cup including past matches, upcoming matches,results, goal scorers etc.",
Action: ListRounds,
Flags: []cli.Flag{
cli.StringFlag{
Name: "date, d",
Usage: "Filter feed by date. Format yyyy-mm-dd e.g 2016-06-18. You can use -d today , for today's feed.",
},
},
},
}
func CommandNotFound(c *cli.Context, command string) {
fmt.Fprintf(os.Stderr, "%s: '%s' is not a %s command. See '%s --help'.", c.App.Name, command, c.App.Name, c.App.Name)
os.Exit(2)
}
func GetJson(url string) ([]byte, error) {
r, err := netClient.Get(url)
if err != nil {
return nil, err
}
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
return nil, err
}
return []byte(b), nil
}