Skip to content

Commit

Permalink
Added global --silent flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy McPhillips committed Mar 13, 2021
1 parent cbe51d5 commit c72dab0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ package:
clean:
go clean ./...
rm -rf ./.build/*
rm -rf ./.gopath/pkg
chmod -R +w ./.gopath
rm -rf ./.gopath
7 changes: 7 additions & 0 deletions go/cli/command_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type CommandContext struct {
Args []string
Flags *flag.FlagSet
Quiet *bool
Silent *bool
InReader io.Reader
OutWriter io.Writer
ErrWriter io.Writer
Expand All @@ -48,6 +49,7 @@ func NewCommandContext(pc *ProgramContext, commands *CommandSet) (cc *CommandCon
cc.Providers = make(map[string]func(cc *CommandContext) interface{})

cc.Quiet = cc.Flags.Bool("quiet", false, "Discard normal command output")
cc.Silent = cc.Flags.Bool("silent", false, "Discard normal and error command output")

return
}
Expand Down Expand Up @@ -122,6 +124,11 @@ func (cc *CommandContext) ParseCommandFlags() (err error) {
cc.OutWriter = NullWriter{}
}

if *cc.Silent {
cc.OutWriter = NullWriter{}
cc.ErrWriter = NullWriter{}
}

return
}

Expand Down

0 comments on commit c72dab0

Please sign in to comment.