Skip to content

Commit

Permalink
feat: add quiet flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rfyiamcool committed Oct 23, 2024
1 parent 05e2b67 commit 3f0b4b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pkg/argparse/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
}
}

Expand Down
13 changes: 4 additions & 9 deletions pkg/client/generic_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package client

import (
"context"
"fmt"
"os"

"github.com/bytedance/gopkg/cloud/metainfo"
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Config struct {
MetaPersistent map[string]string
MetaBackward bool
BizError bool
RespFileName string
Quiet bool
}

type ConfigBuilder interface {
Expand Down

0 comments on commit 3f0b4b3

Please sign in to comment.