toolcontext: add `ToolContext::quit` to perform a correct shutdown of the program
authorJean Privat <jean@pryen.org>
Sat, 7 Nov 2015 04:08:24 +0000 (23:08 -0500)
committerJean Privat <jean@pryen.org>
Sat, 7 Nov 2015 04:08:24 +0000 (23:08 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/toolcontext.nit

index bdd6338..850781e 100644 (file)
@@ -169,6 +169,16 @@ class ToolContext
                return tags.has("all") or tags.has(tag)
        end
 
+       # Output all current stacked messages, total and exit the program
+       #
+       # If there is no error, exit with 0, else exit with 1.
+       fun quit
+       do
+               check_errors
+               errors_info
+               if error_count > 0 then exit(1) else exit(0)
+       end
+
        # Output all current stacked messages
        #
        # Return true if no errors occurred.