-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.go
49 lines (45 loc) · 967 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
package main
import (
"fmt"
"os"
"runtime"
"github.com/logrusorgru/aurora"
"github.com/urfave/cli"
)
var (
buildVersion = "1.1.0"
commands = []cli.Command{
{
Name: "mysql",
Usage: `generate ent schema`,
Subcommands: []cli.Command{
{
Name: "ddl",
Usage: `generate mysql ent schema from ddl`,
Flags: []cli.Flag{
cli.StringFlag{
Name: "src, s",
Usage: "the path or path globbing patterns of the ddl",
},
cli.StringFlag{
Name: "dir, d",
Value: "./ent/schema",
Usage: "the target dir",
},
},
Action: MysqlDDL,
},
},
},
}
)
func main() {
app := cli.NewApp()
app.Usage = "a cli tool to generate code"
app.Version = fmt.Sprintf("%s %s/%s", buildVersion, runtime.GOOS, runtime.GOARCH)
app.Commands = commands
// cli already print error messages
if err := app.Run(os.Args); err != nil {
fmt.Println(aurora.Red("error: " + err.Error()))
}
}