@@ -269,8 +269,8 @@ func init() {
269
269
// Support -h for help
270
270
cli .HelpFlag .Short ('h' )
271
271
272
- if len (os .Args ) <= 1 && isatty . IsTerminal ( os .Stdout . Fd ()) {
273
- args := tui .Run ()
272
+ if isatty . IsTerminal ( os . Stdout . Fd ()) && ( len (os .Args ) <= 1 || os .Args [ 1 ] == analyzeCmd . FullCommand ()) {
273
+ args := tui .Run (os . Args [ 1 :] )
274
274
if len (args ) == 0 {
275
275
os .Exit (0 )
276
276
}
@@ -520,46 +520,56 @@ func run(state overseer.State) {
520
520
return
521
521
}
522
522
523
- topLevelSubCommand , _ , _ := strings .Cut (cmd , " " )
524
- switch topLevelSubCommand {
525
- case analyzeCmd .FullCommand ():
526
- analyzer .Run (cmd )
527
- default :
528
- metrics , err := runSingleScan (ctx , cmd , engConf )
529
- if err != nil {
530
- logFatal (err , "error running scan" )
531
- }
532
-
533
- verificationCacheMetrics := struct {
534
- Hits int32
535
- Misses int32
536
- HitsWasted int32
537
- AttemptsSaved int32
538
- VerificationTimeSpentMS int64
539
- }{
540
- Hits : verificationCacheMetrics .ResultCacheHits .Load (),
541
- Misses : verificationCacheMetrics .ResultCacheMisses .Load (),
542
- HitsWasted : verificationCacheMetrics .ResultCacheHitsWasted .Load (),
543
- AttemptsSaved : verificationCacheMetrics .CredentialVerificationsSaved .Load (),
544
- VerificationTimeSpentMS : verificationCacheMetrics .FromDataVerifyTimeSpentMS .Load (),
545
- }
546
-
547
- // Print results.
548
- logger .Info ("finished scanning" ,
549
- "chunks" , metrics .ChunksScanned ,
550
- "bytes" , metrics .BytesScanned ,
551
- "verified_secrets" , metrics .VerifiedSecretsFound ,
552
- "unverified_secrets" , metrics .UnverifiedSecretsFound ,
553
- "scan_duration" , metrics .ScanDuration .String (),
554
- "trufflehog_version" , version .BuildVersion ,
555
- "verification_caching" , verificationCacheMetrics ,
556
- )
557
-
558
- if metrics .hasFoundResults && * fail {
559
- logger .V (2 ).Info ("exiting with code 183 because results were found" )
560
- os .Exit (183 )
561
- }
523
+ metrics , err := runSingleScan (ctx , cmd , engConf )
524
+ if err != nil {
525
+ logFatal (err , "error running scan" )
526
+ }
527
+
528
+ verificationCacheMetricsSnapshot := struct {
529
+ Hits int32
530
+ Misses int32
531
+ HitsWasted int32
532
+ AttemptsSaved int32
533
+ VerificationTimeSpentMS int64
534
+ }{
535
+ Hits : verificationCacheMetrics .ResultCacheHits .Load (),
536
+ Misses : verificationCacheMetrics .ResultCacheMisses .Load (),
537
+ HitsWasted : verificationCacheMetrics .ResultCacheHitsWasted .Load (),
538
+ AttemptsSaved : verificationCacheMetrics .CredentialVerificationsSaved .Load (),
539
+ VerificationTimeSpentMS : verificationCacheMetrics .FromDataVerifyTimeSpentMS .Load (),
540
+ }
541
+
542
+ // Print results.
543
+ logger .Info ("finished scanning" ,
544
+ "chunks" , metrics .ChunksScanned ,
545
+ "bytes" , metrics .BytesScanned ,
546
+ "verified_secrets" , metrics .VerifiedSecretsFound ,
547
+ "unverified_secrets" , metrics .UnverifiedSecretsFound ,
548
+ "scan_duration" , metrics .ScanDuration .String (),
549
+ "trufflehog_version" , version .BuildVersion ,
550
+ "verification_caching" , verificationCacheMetricsSnapshot ,
551
+ )
552
+
553
+ if metrics .hasFoundResults && * fail {
554
+ logger .V (2 ).Info ("exiting with code 183 because results were found" )
555
+ os .Exit (183 )
562
556
}
557
+
558
+ // Print results.
559
+ logger .Info ("finished scanning" ,
560
+ "chunks" , metrics .ChunksScanned ,
561
+ "bytes" , metrics .BytesScanned ,
562
+ "verified_secrets" , metrics .VerifiedSecretsFound ,
563
+ "unverified_secrets" , metrics .UnverifiedSecretsFound ,
564
+ "scan_duration" , metrics .ScanDuration .String (),
565
+ "trufflehog_version" , version .BuildVersion ,
566
+ )
567
+
568
+ if metrics .hasFoundResults && * fail {
569
+ logger .V (2 ).Info ("exiting with code 183 because results were found" )
570
+ os .Exit (183 )
571
+ }
572
+
563
573
}
564
574
565
575
func compareScans (ctx context.Context , cmd string , cfg engine.Config ) error {
0 commit comments