wujian_develop_tool/main.go

112 lines
2.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package main
import (
"os"
"github.com/fatih/color"
"github.com/urfave/cli/v2"
)
func main() {
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: "配置文件",
},
}
app := cli.NewApp()
app = &cli.App{
Name: "wdt",
Usage: "无间开发者工具箱",
Version: "v0.0.1",
EnableBashCompletion: true,
Flags: flags,
Commands: cli.Commands{
&cli.Command{
Name: "api",
Aliases: []string{"a"},
Usage: "api应用",
Flags: flags,
Subcommands: []*cli.Command{
{
Name: "new",
Usage: "创建一个api应用",
Action: ActionNewApi,
},
{
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,
},
},
},
},
}
err := app.Run(os.Args)
if err != nil {
color.Red("%s", err.Error())
}
}