-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
93 lines (90 loc) · 2.1 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"fmt"
"github.com/NucoTech/nuco-backend-cli/commit"
"github.com/NucoTech/nuco-backend-cli/docs"
"github.com/NucoTech/nuco-backend-cli/initProj"
"github.com/NucoTech/nuco-backend-cli/serve"
"github.com/NucoTech/nuco-backend-cli/update"
"github.com/NucoTech/nuco-backend-cli/utils"
"github.com/urfave/cli/v2"
"log"
"os"
"runtime"
)
func main() {
app := &cli.App{
Commands: []*cli.Command{
{
Name: "init",
Usage: "初始化工程配置文件",
Action: initProj.RegisterInitCommandAction(),
},
{
Name: "commit",
Usage: "生成标准commit提交信息",
Action: commit.RegisterCommitCommandAction(),
},
{
Name: "docs",
Usage: "生成文档模板",
Action: docs.RegisterDocsCommandAction(),
},
{
Name: "serve",
Usage: "启动静态服务",
Action: serve.RegisterServeCommandAction(),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "port",
Aliases: []string{"p"},
Usage: "指定端口号 (default: 5001)",
},
&cli.BoolFlag{
Aliases: []string{"S"},
Usage: "启动https服务",
},
},
},
{
Name: "update",
Usage: "更新nbc工具",
Action: update.RegisterUpdateCommandAction(),
},
//{
// Name: "config",
// Usage: "打印nbc配置",
// Action: config.RegisterConfigCommandAction(),
// Subcommands: []*cli.Command{
// {
// Name: "init",
// Usage: "导出配置文件",
// Action: config.RegisterConfigInitCommandAction(),
// },
// },
//},
{
Name: "info",
Usage: "打印工具信息",
Action: func(context *cli.Context) error {
fmt.Println("工具仓库地址: https://github.com/NucoTech/nuco-backend-cli")
fmt.Printf("OS:\t%s\nArch:\t%s\n", runtime.GOOS, runtime.GOARCH)
fmt.Printf("Version:\t%s\n", utils.VERSION)
return nil
},
},
{
Name: "version",
Usage: "打印版本信息",
Action: func(context *cli.Context) error {
fmt.Println(utils.VERSION)
return nil
},
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}