goal_failed msg
)
+let guard fn arg =
+ try fn arg; true
+ with
+ | Goal_result (Goal_failed msg) ->
+ prerr_endline ("error: " ^ msg);
+ false
+ | exn ->
+ prerr_endline (Printexc.to_string exn);
+ false
+
(* Run the program. *)
-let init () =
+let rec init () =
let prog = Sys.executable_name in
let prog = Filename.basename prog in
let args = List.rev !args in
(* Was a goal named on the command line? *)
- match args with
+ (match args with
| name :: args ->
(match get_goal name with
- | Some fn -> fn args
+ | Some fn ->
+ exit (if guard fn args then 0 else 1)
| None ->
eprintf "error: no goal called '%s' was found.\n" name;
eprintf "Use %s -l to list all published goals in this script.\n" name;