Skip to content

Commit

Permalink
Add "-quiet" flag that suppresses output to stdout when set
Browse files Browse the repository at this point in the history
Fixes #152
  • Loading branch information
nmiyake committed May 21, 2017
1 parent fefd94b commit 416feff
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/mockery/mockery.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/vektra/mockery/mockery"
"runtime/pprof"
"syscall"
)

const regexMetadataChars = "\\.+*?()|[]{}^$"
Expand All @@ -27,6 +28,7 @@ type Config struct {
fNote string
fProfile string
fVersion bool
quiet bool
}

func main() {
Expand All @@ -37,6 +39,11 @@ func main() {
var err error
var limitOne bool

if config.quiet {
// if "quiet" flag is set, set os.Stdout to /dev/null to suppress all output to Stdout
os.Stdout = os.NewFile(uintptr(syscall.Stdout), os.DevNull)
}

if config.fVersion {
fmt.Println(mockery.SemVer)
return
Expand Down Expand Up @@ -125,6 +132,7 @@ func parseConfigFromArgs(args []string) Config {
flagSet.StringVar(&config.fNote, "note", "", "comment to insert into prologue of each generated file")
flagSet.StringVar(&config.fProfile, "cpuprofile", "", "write cpu profile to file")
flagSet.BoolVar(&config.fVersion, "version", false, "prints the installed version of mockery")
flagSet.BoolVar(&config.quiet, "quiet", false, "suppress output to stdout")

flagSet.Parse(args[1:])

Expand Down

0 comments on commit 416feff

Please sign in to comment.