wujian_develop_tool/main.go

112 lines
2.1 KiB
Go
Raw Normal View History

2022-01-05 20:25:29 +08:00
package main
import (
"os"
2022-01-06 20:27:18 +08:00
"github.com/fatih/color"
2022-01-05 20:25:29 +08:00
"github.com/urfave/cli/v2"
)
func main() {
2022-01-06 00:19:22 +08:00
flags := []cli.Flag{
&cli.BoolFlag{
Name: "all",
Aliases: []string{"a"},
Usage: "所有应用",
},
&cli.StringSliceFlag{
Name: "app",
Usage: "app列表",
},
&cli.StringFlag{
Name: "config",
Aliases: []string{"c"},
Usage: "配置文件",
},
}
2022-01-05 20:25:29 +08:00
app := cli.NewApp()
app = &cli.App{
2022-01-06 20:27:18 +08:00
Name: "wdt",
2022-01-05 20:25:29 +08:00
Usage: "无间开发者工具箱",
2022-01-06 23:34:37 +08:00
Version: "v1.0.0",
2022-01-05 20:25:29 +08:00
EnableBashCompletion: true,
2022-01-06 00:19:22 +08:00
Flags: flags,
2022-01-05 20:25:29 +08:00
Commands: cli.Commands{
&cli.Command{
2022-01-06 20:27:18 +08:00
Name: "api",
Aliases: []string{"a"},
Usage: "api应用",
Flags: flags,
2022-01-06 00:19:22 +08:00
Subcommands: []*cli.Command{
{
Name: "new",
Usage: "创建一个api应用",
Action: ActionNewApi,
2022-01-05 20:25:29 +08:00
},
2022-01-06 20:27:18 +08:00
{
Name: "list",
Usage: "api应用列表",
Action: ActionListApi,
},
{
Name: "fix",
Usage: "api应用修复",
Action: ActionFixApi,
},
},
},
&cli.Command{
Name: "service",
Aliases: []string{"s"},
Usage: "service应用",
Flags: flags,
Subcommands: []*cli.Command{
{
Name: "new",
Usage: "创建一个service应用",
2022-01-06 23:34:37 +08:00
Action: ActionNewService,
2022-01-06 20:27:18 +08:00
},
{
Name: "list",
Usage: "service应用列表",
2022-01-06 23:34:37 +08:00
Action: ActionListService,
2022-01-06 20:27:18 +08:00
},
{
Name: "fix",
Usage: "service应用修复",
2022-01-06 23:34:37 +08:00
Action: ActionFixService,
2022-01-06 20:27:18 +08:00
},
},
},
&cli.Command{
Name: "ci",
Usage: "ci/cd部署",
Subcommands: []*cli.Command{
{
Name: "build",
Usage: "创建新的构建",
ArgsUsage: "需要构建的app如 api-lark service-lark",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "commit",
Aliases: []string{"m"},
Usage: "commit sha",
},
},
Action: ActionBuildCI,
},
2022-01-05 20:25:29 +08:00
},
},
},
}
err := app.Run(os.Args)
if err != nil {
2022-01-06 20:27:18 +08:00
color.Red("%s", err.Error())
2022-01-05 20:25:29 +08:00
}
}