Add verbose flag (#1696)

Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
anqiansong
2022-03-22 21:00:26 +08:00
committed by GitHub
parent fe262766b4
commit 0aeb49a6b0
6 changed files with 82 additions and 31 deletions

View File

@@ -23,6 +23,7 @@ func RPCNew(c *cli.Context) error {
home := c.String("home")
remote := c.String("remote")
branch := c.String("branch")
verbose := c.Bool("verbose")
if len(remote) > 0 {
repo, _ := util.CloneIntoGitHome(remote, branch)
if len(repo) > 0 {
@@ -52,7 +53,7 @@ func RPCNew(c *cli.Context) error {
ctx.IsGooglePlugin = true
ctx.Output = filepath.Dir(src)
ctx.ProtocCmd = fmt.Sprintf("protoc -I=%s %s --go_out=%s --go-grpc_out=%s", filepath.Dir(src), filepath.Base(src), filepath.Dir(src), filepath.Dir(src))
g := generator.NewGenerator(style)
g := generator.NewGenerator(style, verbose)
return g.Generate(&ctx)
}

View File

@@ -42,6 +42,7 @@ func ZRPC(c *cli.Context) error {
home := c.String("home")
remote := c.String("remote")
branch := c.String("branch")
verbose := c.Bool("verbose")
if len(grpcOutList) == 0 {
return errInvalidGrpcOutput
}
@@ -107,7 +108,7 @@ func ZRPC(c *cli.Context) error {
ctx.IsGooglePlugin = isGooglePlugin
ctx.Output = zrpcOut
ctx.ProtocCmd = strings.Join(protocArgs, " ")
g := generator.NewGenerator(style)
g := generator.NewGenerator(style, verbose)
return g.Generate(&ctx)
}
@@ -117,11 +118,13 @@ func removeGoctlFlag(args []string) []string {
for step < len(args) {
arg := args[step]
switch {
case arg == "--style", arg == "--home", arg == "--zrpc_out":
case arg == "--style", arg == "--home", arg == "--zrpc_out", arg == "--verbose", arg == "-v":
step += 2
continue
case strings.HasPrefix(arg, "--style="),
strings.HasPrefix(arg, "--home="),
strings.HasPrefix(arg, "--verbose="),
strings.HasPrefix(arg, "-v="),
strings.HasPrefix(arg, "--zrpc_out="):
step += 1
continue