diff --git a/tools/goctl/api/new/newservice.go b/tools/goctl/api/new/newservice.go index cc5fc1b3c..7ea373cf5 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 9f4dda490..fc14a3341 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]", + }, }, }, {