@@ -36,6 +36,10 @@ func main() {
36
36
if err != nil {
37
37
fail (err .Error ())
38
38
}
39
+ if setExitStatus {
40
+ conf .ErrorCode = 1
41
+ conf .WarningCode = 1
42
+ }
39
43
40
44
if len (excludePaths ) == 0 { // if no excludes were set in the command line
41
45
excludePaths = conf .Exclude // use those from the configuration
@@ -135,11 +139,14 @@ func (i *arrayFlags) Set(value string) error {
135
139
return nil
136
140
}
137
141
138
- var configPath string
139
- var excludePaths arrayFlags
140
- var formatterName string
141
- var help bool
142
- var versionFlag bool
142
+ var (
143
+ configPath string
144
+ excludePaths arrayFlags
145
+ formatterName string
146
+ help bool
147
+ versionFlag bool
148
+ setExitStatus bool
149
+ )
143
150
144
151
var originalUsage = flag .Usage
145
152
@@ -188,10 +195,11 @@ func init() {
188
195
189
196
// command line help strings
190
197
const (
191
- configUsage = "path to the configuration TOML file, defaults to $HOME/revive.toml, if present (i.e. -config myconf.toml)"
192
- excludeUsage = "list of globs which specify files to be excluded (i.e. -exclude foo/...)"
193
- formatterUsage = "formatter to be used for the output (i.e. -formatter stylish)"
194
- versionUsage = "get revive version"
198
+ configUsage = "path to the configuration TOML file, defaults to $HOME/revive.toml, if present (i.e. -config myconf.toml)"
199
+ excludeUsage = "list of globs which specify files to be excluded (i.e. -exclude foo/...)"
200
+ formatterUsage = "formatter to be used for the output (i.e. -formatter stylish)"
201
+ versionUsage = "get revive version"
202
+ exitStatusUsage = "set exit status to 1 if any issues are found, overwrites errorCode and warningCode in config"
195
203
)
196
204
197
205
defaultConfigPath := buildDefaultConfigPath ()
@@ -200,6 +208,7 @@ func init() {
200
208
flag .Var (& excludePaths , "exclude" , excludeUsage )
201
209
flag .StringVar (& formatterName , "formatter" , "" , formatterUsage )
202
210
flag .BoolVar (& versionFlag , "version" , false , versionUsage )
211
+ flag .BoolVar (& setExitStatus , "set_exit_status" , false , exitStatusUsage )
203
212
flag .Parse ()
204
213
205
214
// Output build info (version, commit, date and builtBy)
0 commit comments