浏览代码

go-zero tools ,fix a func,api new can not choose style (#1356)

JiangYiJun 3 年之前
父节点
当前提交
a67c118dcf
共有 2 个文件被更改,包括 9 次插入1 次删除
  1. 5 1
      tools/goctl/api/new/newservice.go
  2. 4 0
      tools/goctl/goctl.go

+ 5 - 1
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
 }

+ 4 - 0
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]",
+					},
 				},
 			},
 			{