Skip to content

Commit

Permalink
Merge pull request #153 from nmiyake/quietFlag
Browse files Browse the repository at this point in the history
Add "-quiet" flag that suppresses output to stdout when set
  • Loading branch information
evanphx authored May 22, 2017
2 parents fefd94b + 8101ee5 commit b6f6c13
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion 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,9 +39,14 @@ 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
return
} else if config.fName != "" && config.fAll {
fmt.Fprintln(os.Stderr, "Specify -name or -all, but not both")
os.Exit(1)
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 b6f6c13

Please sign in to comment.