112 lines
2.0 KiB
Go
112 lines
2.0 KiB
Go
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())
|
||
}
|
||
}
|