Commit 1fad466 1 parent f23f1b5 commit 1fad466 Copy full SHA for 1fad466
File tree 3 files changed +14
-7
lines changed
3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package console
3
3
import (
4
4
"context"
5
5
"fmt"
6
- "strings"
7
6
"time"
8
7
9
8
"github.com/Checkmarx/kics/internal/console/printer"
@@ -128,10 +127,7 @@ func Execute() error {
128
127
129
128
if err := rootCmd .ExecuteContext (ctx ); err != nil {
130
129
sentry .CaptureException (err )
131
- if ! (strings .HasPrefix (err .Error (), "unknown shorthand flag" ) ||
132
- strings .HasPrefix (err .Error (), "unknown flag" ) ||
133
- strings .HasPrefix (err .Error (), "unknown command" ) ||
134
- strings .HasPrefix (err .Error (), "initialization error -" )) {
130
+ if printer .IsInitialized () {
135
131
log .Err (err ).Msg ("Failed to run application" )
136
132
}
137
133
return err
Original file line number Diff line number Diff line change 57
57
outFileLogger interface {}
58
58
outConsoleLogger interface {}
59
59
60
- loggerFile interface {}
60
+ loggerFile interface {}
61
+ initialized bool
61
62
)
62
63
63
64
// SetupPrinter - configures stdout and log options with given FlagSet
@@ -101,10 +102,15 @@ func SetupPrinter(flags *pflag.FlagSet) error {
101
102
if err != nil {
102
103
return err
103
104
}
104
-
105
+ initialized = true
105
106
return nil
106
107
}
107
108
109
+ // IsInitialized returns true if printer is ready, false otherwise
110
+ func IsInitialized () bool {
111
+ return initialized
112
+ }
113
+
108
114
func getFlagValue (flagName string , flags * pflag.FlagSet ) bool {
109
115
v , _ := strconv .ParseBool (flags .Lookup (flagName ).Value .String ())
110
116
return v
Original file line number Diff line number Diff line change 8
8
"testing"
9
9
10
10
"github.com/rs/zerolog"
11
+ "github.com/stretchr/testify/require"
11
12
)
12
13
13
14
type args struct {
@@ -306,3 +307,7 @@ func TestPrinter_NoColor(t *testing.T) {
306
307
})
307
308
}
308
309
}
310
+
311
+ func TestPrinter_IsInitialized (t * testing.T ) {
312
+ require .False (t , IsInitialized ())
313
+ }
You can’t perform that action at this time.
0 commit comments