add whether to generate rpc client option (#3361)
Co-authored-by: admin <admin@admindeMacBook-Pro.local>
This commit is contained in:
@@ -28,6 +28,8 @@ type ZRpcContext struct {
|
||||
Output string
|
||||
// Multiple is the flag to indicate whether the proto file is generated in multiple mode.
|
||||
Multiple bool
|
||||
// Whether to generate rpc client
|
||||
IsGenClient bool
|
||||
}
|
||||
|
||||
// Generate generates a rpc service, through the proto file,
|
||||
@@ -100,7 +102,9 @@ func (g *Generator) Generate(zctx *ZRpcContext) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = g.GenCall(dirCtx, proto, g.cfg, zctx)
|
||||
if zctx.IsGenClient {
|
||||
err = g.GenCall(dirCtx, proto, g.cfg, zctx)
|
||||
}
|
||||
|
||||
console.NewColorConsole().MarkDone()
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ func mkdir(ctx *ctx.ProjectContext, proto parser.Proto, conf *conf.Config, c *ZR
|
||||
return filepath.ToSlash(pkg), nil
|
||||
}
|
||||
|
||||
var callClientDir string
|
||||
if !c.Multiple {
|
||||
callDir := filepath.Join(ctx.WorkDir,
|
||||
strings.ToLower(stringx.From(proto.Service[0].Name).ToCamel()))
|
||||
@@ -98,23 +99,18 @@ func mkdir(ctx *ctx.ProjectContext, proto parser.Proto, conf *conf.Config, c *ZR
|
||||
}
|
||||
callDir = filepath.Join(ctx.WorkDir, clientDir)
|
||||
}
|
||||
inner[call] = Dir{
|
||||
Filename: callDir,
|
||||
Package: filepath.ToSlash(filepath.Join(ctx.Path,
|
||||
strings.TrimPrefix(callDir, ctx.Dir))),
|
||||
Base: filepath.Base(callDir),
|
||||
GetChildPackage: func(childPath string) (string, error) {
|
||||
return getChildPackage(callDir, childPath)
|
||||
},
|
||||
}
|
||||
callClientDir = callDir
|
||||
} else {
|
||||
callClientDir = clientDir
|
||||
}
|
||||
if c.IsGenClient {
|
||||
inner[call] = Dir{
|
||||
Filename: clientDir,
|
||||
Filename: callClientDir,
|
||||
Package: filepath.ToSlash(filepath.Join(ctx.Path,
|
||||
strings.TrimPrefix(clientDir, ctx.Dir))),
|
||||
Base: filepath.Base(clientDir),
|
||||
strings.TrimPrefix(callClientDir, ctx.Dir))),
|
||||
Base: filepath.Base(callClientDir),
|
||||
GetChildPackage: func(childPath string) (string, error) {
|
||||
return getChildPackage(clientDir, childPath)
|
||||
return getChildPackage(callClientDir, childPath)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user