-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
53 lines (46 loc) · 1009 Bytes
/
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
package main
import (
"fmt"
"os"
"path"
"github.com/codegangsta/cli"
"github.com/f6v/poeditor/client"
)
const (
paramProjectPath = "path"
)
func main() {
app := cli.NewApp()
app.Name = "poeditor"
app.Usage = "Update i18n resources from POEditor"
app.Version = "1.0.0"
app.Commands = []cli.Command{
{
Name: "update",
Usage: "Update translations",
Action: func(c *cli.Context) {
projectPath := c.String(paramProjectPath)
configPath := path.Join(projectPath + "/poeditor.json")
config, err := client.FromFile(configPath)
if err != nil {
fmt.Printf("Can't load config: %q\n", err)
return
}
client := client.NewClient(config)
err = client.Update()
if err != nil {
fmt.Printf("Failed to updae: %q\n", err)
} else {
fmt.Printf("Updated resources\n")
}
},
Flags: []cli.Flag{
cli.StringFlag{
Name: paramProjectPath,
Usage: "Project path which contains config file",
},
},
},
}
app.Run(os.Args)
}