Skip to content

Commit

Permalink
feat(cmd): add silent option repo gc command
Browse files Browse the repository at this point in the history
closes #7129
  • Loading branch information
will7200 committed Apr 13, 2020
1 parent 5ecf44a commit e3fdc5a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/commands/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type GcResult struct {
const (
repoStreamErrorsOptionName = "stream-errors"
repoQuietOptionName = "quiet"
repoSilentOptionName = "silent"
)

var repoGcCmd = &cmds.Command{
Expand All @@ -65,6 +66,7 @@ order to reclaim hard disk space.
Options: []cmds.Option{
cmds.BoolOption(repoStreamErrorsOptionName, "Stream errors."),
cmds.BoolOption(repoQuietOptionName, "q", "Write minimal output."),
cmds.BoolOption(repoSilentOptionName, "Write no output."),
},
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
n, err := cmdenv.GetNode(env)
Expand Down Expand Up @@ -111,6 +113,11 @@ order to reclaim hard disk space.
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, gcr *GcResult) error {
quiet, _ := req.Options[repoQuietOptionName].(bool)
silent, _ := req.Options[repoSilentOptionName].(bool)

if silent {
return nil
}

if gcr.Error != "" {
_, err := fmt.Fprintf(w, "Error: %s\n", gcr.Error)
Expand Down

0 comments on commit e3fdc5a

Please sign in to comment.