let goal_failed msg = raise (Goal_result (Goal_failed msg))
+let depth = ref 0
+let indent fs =
+ let do_indent str =
+ prerr_string "| ";
+ for i = 0 to !depth-1 do prerr_string " " done;
+ prerr_string str;
+ Pervasives.flush Pervasives.stderr
+ in
+ ksprintf do_indent fs
+
let target v =
if v then raise (Goal_result Goal_OK)
let target_all vs = target (List.fold_left (&&) true vs)
let target_exists vs = target (List.fold_left (||) false vs)
-let require f = f ()
+let require name f =
+ indent "require: %s\n" name;
+ incr depth;
+ let r = (try Either (f ()) with exn -> Or exn) in
+ decr depth;
+ match r with
+ | Either x -> x
+ | Or exn -> raise exn
+
+let _enter_goal name = indent "enter goal: %s\n" name
+let _leave_goal name = indent "leave goal: %s\n" name
type period_t = Seconds | Days | Months | Years
let seconds = (1, Seconds)
goal_failed msg
let file_contains_string filename str =
- let cmd = sprintf "grep -q %s %s" (quote str) (quote filename) in
+ let cmd = sprintf "grep -q -F %s %s" (quote str) (quote filename) in
match Sys.command cmd with
| 0 -> true
| 1 -> false
Pervasives.flush chan;
)
+let memory_list () =
+ with_memory_locked (
+ fun fd ->
+ let chan = in_channel_of_descr fd in
+ let memory : (string, string) Hashtbl.t = input_value chan in
+ Hashtbl.fold (fun key value xs -> (key, value) :: xs) memory []
+ )
+
let published_goals = ref []
let publish name fn = published_goals := (name, fn) :: !published_goals
let get_goal name =