From a67c118dcffe9666bd3870e3bf8aab8c067e79fa Mon Sep 17 00:00:00 2001 From: JiangYiJun Date: Thu, 23 Dec 2021 10:28:46 +0800 Subject: [PATCH] go-zero tools ,fix a func,api new can not choose style (#1356) --- tools/goctl/api/new/newservice.go | 6 +++++- tools/goctl/goctl.go | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/goctl/api/new/newservice.go b/tools/goctl/api/new/newservice.go index cc5fc1b3..7ea373cf 100644 --- a/tools/goctl/api/new/newservice.go +++ b/tools/goctl/api/new/newservice.go @@ -36,6 +36,10 @@ func CreateServiceCommand(c *cli.Context) error { dirName = "greet" } + dirStyle := c.String("style") + if len(dirStyle) == 0 { + dirStyle = conf.DefaultFormat + } if strings.Contains(dirName, "-") { return errors.New("api new command service name not support strikethrough, because this will used by function name") } @@ -78,6 +82,6 @@ func CreateServiceCommand(c *cli.Context) error { return err } - err = gogen.DoGenProject(apiFilePath, abs, conf.DefaultFormat) + err = gogen.DoGenProject(apiFilePath, abs, dirStyle) return err } diff --git a/tools/goctl/goctl.go b/tools/goctl/goctl.go index 9f4dda49..fc14a334 100644 --- a/tools/goctl/goctl.go +++ b/tools/goctl/goctl.go @@ -69,6 +69,10 @@ var commands = []cli.Command{ Name: "home", Usage: "the goctl home path of the template", }, + cli.StringFlag{ + Name: "style", + Usage: "the file naming format, see [https://github.com/zeromicro/go-zero/blob/master/tools/goctl/config/readme.md]", + }, }, }, {