Browse Source

goctl api new should given a service_name explictly (#1688)

fang duan 3 years ago
parent
commit
fadef0ccd9
2 changed files with 8 additions and 6 deletions
  1. 4 3
      tools/goctl/api/new/newservice.go
  2. 4 3
      tools/goctl/goctl.go

+ 4 - 3
tools/goctl/api/new/newservice.go

@@ -20,11 +20,12 @@ var apiTemplate string
 
 // CreateServiceCommand fast create service
 func CreateServiceCommand(c *cli.Context) error {
+	if c.NArg() == 0 {
+		cli.ShowCommandHelpAndExit(c, "new", 1)
+	}
+
 	args := c.Args()
 	dirName := args.First()
-	if len(dirName) == 0 {
-		dirName = "greet"
-	}
 
 	dirStyle := c.String("style")
 	if len(dirStyle) == 0 {

+ 4 - 3
tools/goctl/goctl.go

@@ -137,9 +137,10 @@ var commands = []cli.Command{
 		Action: apigen.ApiCommand,
 		Subcommands: []cli.Command{
 			{
-				Name:   "new",
-				Usage:  "fast create api service",
-				Action: new.CreateServiceCommand,
+				Name:      "new",
+				Usage:     "fast create api service",
+				UsageText: "example: goctl api new [options] server_name",
+				Action:    new.CreateServiceCommand,
 				Flags: []cli.Flag{
 					cli.StringFlag{
 						Name: "home",