forked from liudanking/didi-car-rank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (58 loc) · 1.17 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
package main
import (
"os"
log "github.com/liudanking/goutil/logutil"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Version = "0.0.1"
app.Usage = "Collect didi gas station data, and rank most popular didi cars"
app.EnableBashCompletion = true
app.Commands = []cli.Command{
cli.Command{
Name: "collect_data",
Usage: "Collect didi gas station data",
Flags: []cli.Flag{
cli.StringFlag{
Name: "listen, l",
Usage: "listen addr",
Value: ":8086",
},
cli.StringFlag{
Name: "dir, d",
Usage: "directory for saving data",
Value: "./data",
},
},
Action: collectData,
},
cli.Command{
Name: "analysis",
Usage: "Analysis collected data and output most popular didi cars",
Flags: []cli.Flag{
cli.StringFlag{
Name: "dir, d",
Usage: "data directory",
Value: "./data",
},
cli.StringFlag{
Name: "city, c",
Usage: "city name",
Value: "成都市",
},
cli.IntFlag{
Name: "top, t",
Usage: "output top n",
Value: 20,
},
},
Action: analysisCity,
},
}
err := app.Run(os.Args)
if err != nil {
log.Error(err.Error())
return
}
}