diff --git a/pkg/argparse/args.go b/pkg/argparse/args.go index a6b8682..8ca3bb9 100644 --- a/pkg/argparse/args.go +++ b/pkg/argparse/args.go @@ -107,7 +107,7 @@ func (a *Argument) buildFlags() *flag.FlagSet { f.BoolVar(&a.version, "version", false, "Show the version of kitexcall.") - f.StringVar(&a.RespFileName, "o", "", "Specify the file name to save the rpc response.") + f.BoolVar(&a.Quiet, "quiet", false, "Enable only print rpc response.") return f } @@ -281,7 +281,7 @@ func (a *Argument) BuildConfig() *config.Config { MetaPersistent: a.MetaPersistent, MetaBackward: a.MetaBackward, BizError: a.BizError, - RespFileName: a.RespFileName, + Quiet: a.Quiet, } } diff --git a/pkg/client/generic_client.go b/pkg/client/generic_client.go index e8c76b7..c572122 100644 --- a/pkg/client/generic_client.go +++ b/pkg/client/generic_client.go @@ -18,6 +18,7 @@ package client import ( "context" + "fmt" "os" "github.com/bytedance/gopkg/cloud/metainfo" @@ -83,16 +84,10 @@ func (c *GenericClientBase) Output() error { return err } - log.Success() - - if c.Conf.RespFileName == "" { - log.Println(result) - } else { - err = os.WriteFile(c.Conf.RespFileName, []byte(result), 0644) - if err != nil { - return err - } + if !c.Conf.Quiet { + log.Success() } + fmt.Print(result) if c.Conf.MetaBackward { log.Println("\033[32mReceived metainfo from server: \033[0m") diff --git a/pkg/config/config.go b/pkg/config/config.go index c83cc6c..d662d45 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -46,7 +46,7 @@ type Config struct { MetaPersistent map[string]string MetaBackward bool BizError bool - RespFileName string + Quiet bool } type ConfigBuilder interface {