mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
add go-grpc_opt and go_opt for grpc new command (#1769)
Co-authored-by: zhouyy <zhouyy@ickey.cn>
This commit is contained in:
parent
305587aa81
commit
14bf2f33f7
@ -538,6 +538,14 @@ var commands = []cli.Command{
|
||||
Usage: `generate rpc demo service`,
|
||||
UsageText: "example: goctl rpc new [options] service-name",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringSliceFlag{
|
||||
Name: "go_opt",
|
||||
Hidden: true,
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "go-grpc_opt",
|
||||
Hidden: true,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "style",
|
||||
Usage: "the file naming format, see [https://github.com/zeromicro/go-zero/tree/master/tools/goctl/config/readme.md]",
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/zeromicro/go-zero/tools/goctl/rpc/generator"
|
||||
@ -58,6 +59,17 @@ 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))
|
||||
|
||||
grpcOptList := c.StringSlice("go-grpc_opt")
|
||||
if len(grpcOptList) > 0 {
|
||||
ctx.ProtocCmd += " --go-grpc_opt=" + strings.Join(grpcOptList, ",")
|
||||
}
|
||||
|
||||
goOptList := c.StringSlice("go_opt")
|
||||
if len(goOptList) > 0 {
|
||||
ctx.ProtocCmd += " --go_opt=" + strings.Join(goOptList, ",")
|
||||
}
|
||||
|
||||
g := generator.NewGenerator(style, verbose)
|
||||
return g.Generate(&ctx)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user