nitc: add option --stop-on-first-error
authorJean Privat <jean@pryen.org>
Fri, 25 Mar 2011 20:30:14 +0000 (16:30 -0400)
committerJean Privat <jean@pryen.org>
Thu, 31 Mar 2011 14:52:09 +0000 (10:52 -0400)
This option is used nitc in case of crashing because of a stored but not
displayed error.

Signed-off-by: Jean Privat <jean@pryen.org>

src/mmloader.nit
tests/sav/nitc.sav
tests/sav/nitdoc.sav

index 9a6eeb1..5133747 100644 (file)
@@ -83,6 +83,7 @@ class ToolContext
        do
                _messages.add(new Message(l,s))
                _error_count = _error_count + 1
+               if opt_stop_on_first_error.value then check_errors
        end
 
        # Add an error, show errors and quit
@@ -102,6 +103,7 @@ class ToolContext
                else
                        _error_count = _error_count + 1
                end
+               if opt_stop_on_first_error.value then check_errors
        end
 
        # Display an info
@@ -148,13 +150,16 @@ class ToolContext
        # Option --verbose
        readable var _opt_verbose: OptionCount = new OptionCount("Verbose", "-v", "--verbose")
 
+       # Option --stop-on-first-error
+       readable var _opt_stop_on_first_error: OptionBool = new OptionBool("Stop on first error", "--stop-on-first-error")
+
        # Verbose level
        readable var _verbose_level: Int = 0
 
        init
        do
                super
-               option_context.add_option(opt_warn, opt_path, opt_log, opt_log_dir, opt_only_parse, opt_only_metamodel, opt_help, opt_version, opt_verbose)
+               option_context.add_option(opt_warn, opt_stop_on_first_error, opt_path, opt_log, opt_log_dir, opt_only_parse, opt_only_metamodel, opt_help, opt_version, opt_verbose)
        end
 
        # Parse and process the options given on the command line
index 9d1a658..8bbdff9 100644 (file)
@@ -1,5 +1,6 @@
 usage: nitc [options] file...
   -W, --warn                      Show warnings
+  --stop-on-first-error           Stop on first error
   -I, --path                      Set include path for loaders (may be used more than once)
   --log                           Generate various log files
   --log-dir                       Directory where to generate log files
index 96a3837..a9c25e7 100644 (file)
@@ -1,11 +1,12 @@
 usage: nitdoc [options] file...
-  -W, --warn         Show warnings
-  -I, --path         Set include path for loaders (may be used more than once)
-  --log              Generate various log files
-  --log-dir          Directory where to generate log files
-  --only-parse       Only proceed to parse step of loaders
-  --only-metamodel   Stop after meta-model processing
-  -h, -?, --help     Show Help (This screen)
-  --version          Show version and exit
-  -v, --verbose      Verbose
-  -d, --dir          Directory where doc is generated
+  -W, --warn              Show warnings
+  --stop-on-first-error   Stop on first error
+  -I, --path              Set include path for loaders (may be used more than once)
+  --log                   Generate various log files
+  --log-dir               Directory where to generate log files
+  --only-parse            Only proceed to parse step of loaders
+  --only-metamodel        Stop after meta-model processing
+  -h, -?, --help          Show Help (This screen)
+  --version               Show version and exit
+  -v, --verbose           Verbose
+  -d, --dir               Directory where doc is generated