@@ -14,15 +14,14 @@ import (
1414 "syscall"
1515 "time"
1616
17+ "github.com/felixge/fgprof"
18+ "github.com/gorilla/mux"
1719 "github.com/jpillora/overseer"
20+ "github.com/sirupsen/logrus"
1821 "github.com/trufflesecurity/trufflehog/v3/pkg/updater"
1922 "github.com/trufflesecurity/trufflehog/v3/pkg/version"
2023 "gopkg.in/alecthomas/kingpin.v2"
2124
22- "github.com/felixge/fgprof"
23-
24- "github.com/gorilla/mux"
25- "github.com/sirupsen/logrus"
2625 "github.com/trufflesecurity/trufflehog/v3/pkg/common"
2726 "github.com/trufflesecurity/trufflehog/v3/pkg/decoders"
2827 "github.com/trufflesecurity/trufflehog/v3/pkg/engine"
@@ -91,6 +90,16 @@ func init() {
9190 }
9291
9392 cmd = kingpin .MustParse (cli .Parse (os .Args [1 :]))
93+
94+ if * jsonOut {
95+ logrus .SetFormatter (& logrus.JSONFormatter {})
96+ }
97+ if * debug {
98+ logrus .SetLevel (logrus .DebugLevel )
99+ logrus .Debugf ("running version %s" , version .BuildVersion )
100+ } else {
101+ logrus .SetLevel (logrus .InfoLevel )
102+ }
94103}
95104
96105func main () {
@@ -112,25 +121,18 @@ func main() {
112121}
113122
114123func run (state overseer.State ) {
115- if * versionFlag {
124+ if * debug || * versionFlag {
116125 fmt .Println ("trufflehog " + version .BuildVersion )
117- return
126+ if * versionFlag {
127+ return
128+ }
118129 }
119130
120131 // When setting a base commit, chunks must be scanned in order.
121132 if * gitScanSinceCommit != "" {
122133 * concurrency = 1
123134 }
124135
125- if * jsonOut {
126- logrus .SetFormatter (& logrus.JSONFormatter {})
127- }
128- if * debug {
129- logrus .SetLevel (logrus .DebugLevel )
130- } else {
131- logrus .SetLevel (logrus .InfoLevel )
132- }
133-
134136 if * debug {
135137 go func () {
136138 router := mux .NewRouter ()
0 commit comments