2 Star 0 Fork 0

djienet/kratos

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
chenli 提交于 2020-11-02 15:31 +08:00 . init
package main
import (
"os"
"strings"
"github.com/urfave/cli/v2"
)
var appHelpTemplate = `{{if .Usage}}{{.Usage}}{{end}}
USAGE:
kratos new {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}
VERSION:
{{.Version}}{{end}}{{end}}{{if .Description}}
DESCRIPTION:
{{.Description}}{{end}}{{if len .Authors}}
AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
{{range $index, $author := .Authors}}{{if $index}}
{{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}}
OPTIONS:
{{range $index, $option := .VisibleFlags}}{{if $index}}
{{end}}{{$option}}{{end}}{{end}}{{if .Copyright}}
COPYRIGHT:
{{.Copyright}}{{end}}
`
func main() {
app := cli.NewApp()
app.Name = ""
app.Usage = "kratos 新项目创建工具"
app.UsageText = "项目名 [options]"
app.HideVersion = true
app.CustomAppHelpTemplate = appHelpTemplate
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "d",
Value: "",
Usage: "指定项目所在目录",
Destination: &p.path,
},
&cli.BoolFlag{
Name: "http",
Usage: "只使用http 不使用grpc",
Destination: &p.onlyHTTP,
},
&cli.BoolFlag{
Name: "grpc",
Usage: "只使用grpc 不使用http",
Destination: &p.onlyGRPC,
},
&cli.BoolFlag{
Name: "proto",
Usage: "废弃参数 无作用",
Destination: &p.none,
Hidden: true,
},
}
if len(os.Args) < 2 || strings.HasPrefix(os.Args[1], "-") {
app.Run([]string{"-h"})
return
}
p.Name = os.Args[1]
app.Action = runNew
args := append([]string{os.Args[0]}, os.Args[2:]...)
err := app.Run(args)
if err != nil {
panic(err)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/djienet/kratos.git
git@gitee.com:djienet/kratos.git
djienet
kratos
kratos
v1.1.7

搜索帮助