-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
55 lines (47 loc) · 1.07 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
package main
import (
"errors"
"log"
"os"
"github.com/Xuanwo/go-locale"
ei18n "github.com/mylukin/easy-i18n/i18n"
"github.com/urfave/cli/v2"
)
func main() {
// Detect OS language
tag, _ := locale.Detect()
// Set Language
ei18n.SetLang(tag)
appName := "codetool"
app := &cli.App{
HelpName: appName,
Name: appName,
Usage: ei18n.Sprintf(`a tool for managing message translations.`),
Action: func(c *cli.Context) error {
cli.ShowAppHelp(c)
return nil
},
Commands: []*cli.Command{
{
Name: "gen_bot_events",
Usage: ei18n.Sprintf(`Generate Bot Events`),
UsageText: ei18n.Sprintf(`%s gen_bot_events [module] [outfile]`, appName),
Action: func(c *cli.Context) error {
module := c.Args().Get(0)
if module == "" {
return errors.New(ei18n.Sprintf(`[module] can't be empty.`))
}
outFile := c.Args().Get(1)
if outFile == "" {
outFile = "./routers/bot_events.go"
}
return GenBotEvents(module, outFile)
},
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}