@@ -16,6 +16,7 @@ import (
16
16
const (
17
17
ExitCodeOK int = 0
18
18
ExitCodeError int = 1 + iota
19
+ ExitCodeIssuesFound
19
20
)
20
21
21
22
// CLI is the command line object
@@ -37,17 +38,18 @@ type TestCLIOptions struct {
37
38
// Run invokes the CLI with the given arguments.
38
39
func (cli * CLI ) Run (args []string ) int {
39
40
var (
40
- version bool
41
- help bool
42
- debug bool
43
- format string
44
- ignoreModule string
45
- ignoreRule string
46
- configFile string
47
- deepCheck bool
48
- awsAccessKey string
49
- awsSecretKey string
50
- awsRegion string
41
+ version bool
42
+ help bool
43
+ debug bool
44
+ format string
45
+ ignoreModule string
46
+ ignoreRule string
47
+ configFile string
48
+ deepCheck bool
49
+ awsAccessKey string
50
+ awsSecretKey string
51
+ awsRegion string
52
+ errorWithIssues bool
51
53
)
52
54
53
55
// Define option flag parse
@@ -71,6 +73,7 @@ func (cli *CLI) Run(args []string) int {
71
73
flags .StringVar (& awsAccessKey , "aws-access-key" , "" , "AWS access key used in deep check mode." )
72
74
flags .StringVar (& awsSecretKey , "aws-secret-key" , "" , "AWS secret key used in deep check mode." )
73
75
flags .StringVar (& awsRegion , "aws-region" , "" , "AWS region used in deep check mode." )
76
+ flags .BoolVar (& errorWithIssues , "error-with-issues" , false , "return exit status code when issue exists." )
74
77
75
78
// Parse commandline flag
76
79
if err := flags .Parse (args [1 :]); err != nil {
@@ -148,6 +151,10 @@ func (cli *CLI) Run(args []string) int {
148
151
149
152
p := printer .NewPrinter (cli .outStream , cli .errStream )
150
153
p .Print (issues , format )
154
+
155
+ if errorWithIssues && len (issues ) > 0 {
156
+ return ExitCodeIssuesFound
157
+ }
151
158
}
152
159
153
160
return ExitCodeOK
0 commit comments