wujian_develop_tool/main.go

112 lines
2.0 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: "无间开发者工具箱",
Version: "v0.0.1",
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应用",
Action: ActionNewApi,
},
{
Name: "list",
Usage: "service应用列表",
Action: ActionListApi,
},
{
Name: "fix",
Usage: "service应用修复",
Action: ActionFixApi,
},
},
},
&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
}
}