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

@@ -10,25 +10,27 @@ import (
// Generator defines the environment needs of rpc service generation
type Generator struct {
log console.Console
cfg *conf.Config
log console.Console
cfg *conf.Config
verbose bool
}
// NewGenerator returns an instance of Generator
func NewGenerator(style string) *Generator {
func NewGenerator(style string, verbose bool) *Generator {
cfg, err := conf.NewConfig(style)
if err != nil {
log.Fatalln(err)
}
log := console.NewColorConsole()
log := console.NewColorConsole(verbose)
return &Generator{
log: log,
cfg: cfg,
log: log,
cfg: cfg,
verbose: verbose,
}
}
// Prepare provides environment detection generated by rpc service,
// including go environment, protoc, whether protoc-gen-go is installed or not
func (g *Generator) Prepare() error {
return env.Prepare(true, true)
return env.Prepare(true, true, g.verbose)
}