From fadef0ccd97bda008e9ac52a2bead3dd3f5b14b8 Mon Sep 17 00:00:00 2001 From: fang duan Date: Sun, 17 Apr 2022 20:59:18 +0800 Subject: [PATCH] goctl api new should given a service_name explictly (#1688) --- tools/goctl/api/new/newservice.go | 7 ++++--- tools/goctl/goctl.go | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/goctl/api/new/newservice.go b/tools/goctl/api/new/newservice.go index c215c44e..fb872bc7 100644 --- a/tools/goctl/api/new/newservice.go +++ b/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 { diff --git a/tools/goctl/goctl.go b/tools/goctl/goctl.go index 15dc8ed7..9615dedb 100644 --- a/tools/goctl/goctl.go +++ b/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",