瀏覽代碼

show help when running goctl api without any flags (#1678)

close #1676
fang duan 3 年之前
父節點
當前提交
4382ec0e0d
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      tools/goctl/api/apigen/gen.go

+ 4 - 0
tools/goctl/api/apigen/gen.go

@@ -19,6 +19,10 @@ var apiTemplate string
 
 // ApiCommand create api template file
 func ApiCommand(c *cli.Context) error {
+	if c.NumFlags() == 0 {
+		cli.ShowAppHelpAndExit(c, 1)
+	}
+
 	apiFile := c.String("o")
 	if len(apiFile) == 0 {
 		return errors.New("missing -o")