/
main.go
79 lines (76 loc) · 1.48 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"fmt"
"os"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "kratos"
app.Usage = "kratos工具集"
app.Version = Version
app.Commands = []cli.Command{
{
Name: "new",
Aliases: []string{"n"},
Usage: "create new project",
Flags: []cli.Flag{
cli.StringFlag{
Name: "o",
Value: "",
Usage: "project owner for create project",
Destination: &p.Owner,
},
cli.StringFlag{
Name: "d",
Value: "",
Usage: "project directory for create project",
Destination: &p.Path,
},
cli.BoolFlag{
Name: "proto",
Usage: "whether to use protobuf for create project",
Destination: &p.WithGRPC,
},
},
Action: runNew,
},
{
Name: "build",
Aliases: []string{"b"},
Usage: "kratos build",
Action: buildAction,
},
{
Name: "run",
Aliases: []string{"r"},
Usage: "kratos run",
Action: runAction,
},
{
Name: "tool",
Aliases: []string{"t"},
Usage: "kratos tool",
Action: toolAction,
SkipFlagParsing: true,
},
{
Name: "version",
Aliases: []string{"v"},
Usage: "kratos version",
Action: func(c *cli.Context) error {
fmt.Println(getVersion())
return nil
},
},
{
Name: "self-upgrade",
Usage: "kratos self-upgrade",
Action: upgradeAction,
},
}
err := app.Run(os.Args)
if err != nil {
panic(err)
}
}