Release coccinelle-0.1
[bpt/coccinelle.git] / commons / common_extra.ml
1 (* I put those functions here and not in common.ml to try to avoid
2 * as much as possible dependencies in common.ml so I can more easily
3 * make ocaml script that just do a load common.ml without the need
4 * to load many other files (like dumper.ml, or ANSITerminal.ml and
5 * other recursive dependencies).
6 *
7 * Note that you can still use the functions below from an open Common.
8 * You don't need to do a 'open Common_extra'; loading the commons.cma is
9 * enough to make the connexions.
10 *)
11
12
13
14 let execute_and_show_progress len f =
15 let _count = ref 0 in
16 (* kind of continuation passed to f *)
17 let continue_pourcentage () =
18 incr _count;
19 ANSITerminal.set_cursor 1 (-1);
20 ANSITerminal.printf [] "%d / %d" !_count len; flush stdout;
21 in
22 ANSITerminal.printf [] "0 / %d" len; flush stdout;
23 f continue_pourcentage;
24 Common.pr2 ""
25
26 let set_link () =
27 Common._execute_and_show_progress_func := execute_and_show_progress
28
29
30 let _init_execute =
31 set_link ()