This repository has been archived by the owner on Nov 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
cli.go
88 lines (82 loc) · 2.01 KB
/
cli.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
package cli
import "github.com/urfave/cli"
// Run interprets arguments and performs actions
func Run(args []string) {
w := wrapper{}
app := cli.NewApp()
app.Name = "pgoapi-go"
app.Usage = "Command line client for the Pokémon Go API"
app.Author = "Philip Vieira <zee@vall.in>"
app.Version = "0.0.1"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug,d",
Destination: &w.debug,
EnvVar: "PGOAPI_DEBUG",
},
cli.StringFlag{
Name: "username,u",
Destination: &w.username,
EnvVar: "PGOAPI_ACCOUNT_USERNAME",
},
cli.StringFlag{
Name: "password,p",
Destination: &w.password,
EnvVar: "PGOAPI_ACCOUNT_PASSWORD",
},
cli.StringFlag{
Name: "provider",
Destination: &w.provider,
Value: "ptc",
Usage: "Your account provider can be either \"ptc\" or \"google\"",
EnvVar: "PGOAPI_ACCOUNT_PROVIDER",
},
cli.Float64Flag{
Name: "latitude,lat",
Destination: &w.lat,
Value: 0.0,
EnvVar: "PGOAPI_DEFAULT_LATITUDE",
},
cli.Float64Flag{
Name: "longitude,lon",
Destination: &w.lon,
Value: 0.0,
EnvVar: "PGOAPI_DEFAULT_LONGITUDE",
},
cli.Float64Flag{
Name: "altitude,alt",
Destination: &w.alt,
Value: 0.0,
EnvVar: "PGOAPI_DEFAULT_ALTITUDE",
},
cli.Float64Flag{
Name: "accuracy,acc",
Destination: &w.accuracy,
Value: 3.0,
EnvVar: "PGOAPI_DEFAULT_ACCURACY",
},
}
app.Commands = []cli.Command{
{
Name: "access_token",
Usage: "Retrieves an API access token from your credentials",
Action: w.wrap(getAccessToken),
},
{
Name: "player",
Usage: "Retrieves the user's Pokémon Go player profile",
Action: w.wrap(getPlayer),
},
{
Name: "inventory",
Usage: "Retrieves the user's Pokémon Go player inventory",
Action: w.wrap(getInventory),
},
{
Name: "map",
Usage: "Retrieves map data for the player's current location",
Action: w.wrap(getMap),
},
}
app.Run(args)
}