Skip to content

Commit 9f3c0b0

Browse files
cknittcristianoc
authored andcommitted
Add command line option -set-exit-code
1 parent 76485a8 commit 9f3c0b0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Common.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ module Cli = struct
2828

2929
let write = ref false
3030

31+
let exitCode = ref false
32+
3133
(* names to be considered live values *)
3234
let liveNames = ref ([] : string list)
3335

src/Reanalyze.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ let runAnalysis ~cmtRoot ~ppf =
9898
let nIssues = Log_.Stats.report () in
9999
Log_.Stats.clear ();
100100
if !Common.Cli.json then EmitJson.finish ();
101-
if nIssues > 0 then exit 1
101+
if nIssues > 0 && !Common.Cli.exitCode then exit 1
102102

103103
let cli () =
104104
let analysisKindSet = ref false in
@@ -182,6 +182,9 @@ let cli () =
182182
"comma-separated-path-prefixes Consider all values whose path has a \
183183
prefix in the list as live" );
184184
("-noalloc", Unit setNoalloc, "");
185+
( "-set-exit-code",
186+
Set Common.Cli.exitCode,
187+
"Exit with code 1 in case an issue is detected" );
185188
( "-suppress",
186189
String
187190
(fun s ->

0 commit comments

Comments
 (0)