-
Notifications
You must be signed in to change notification settings - Fork 1
/
sayhuuzoku.go
79 lines (74 loc) · 1.62 KB
/
sayhuuzoku.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
package main
import (
"fmt"
"log"
"os"
"github.com/YuheiNakasaka/sayhuuzoku/db"
"github.com/YuheiNakasaka/sayhuuzoku/generator"
"github.com/YuheiNakasaka/sayhuuzoku/scraping"
"github.com/YuheiNakasaka/sayhuuzoku/wakati"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "sayhuuzoku"
app.Version = "0.0.1"
app.Usage = " A new cli application to generate a shop name like 風俗店(huuzoku-shop)."
app.Commands = []cli.Command{
{
Name: "init",
Aliases: []string{"i"},
Usage: "Init database",
Action: func(c *cli.Context) error {
mydb := db.MyDB{}
return mydb.New()
},
},
{
Name: "scraping",
Aliases: []string{"s"},
Usage: "Fetch shop name from http://fujoho.jp/index.php?p=shop_list",
Flags: []cli.Flag{
cli.IntFlag{
Name: "max-page, mp",
Usage: "max page of scraping site",
},
},
Action: func(c *cli.Context) error {
return scraping.Start(c.Int("max-page"))
},
},
{
Name: "wakati",
Aliases: []string{"w"},
Usage: "Create wakati data from shoplist file",
Action: func(c *cli.Context) error {
return wakati.Start()
},
},
{
Name: "generate",
Aliases: []string{"g"},
Usage: "Generate shop name like huuzoku (default: 4 words)",
Flags: []cli.Flag{
cli.IntFlag{
Name: "count, c",
Value: 4,
Usage: "word count",
},
},
Action: func(c *cli.Context) error {
shopName, err := generator.Start(c.Int("count"))
if err != nil {
return err
}
fmt.Println(shopName)
return nil
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}