-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapiDump.ml
48 lines (39 loc) · 1.99 KB
/
apiDump.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(* ************************************************************************** *)
(* Project: Life - the game, Official OCaml SDK *)
(* Author: db0 ([email protected], http://db0.fr/) *)
(* Latest Version is on GitHub: https://github.com/Life-the-game/SDK-OCaml *)
(* ************************************************************************** *)
(* ************************************************************************** *)
(* Tools *)
(* ************************************************************************** *)
let lprint_string str = output_string !ApiConf.dump_output str; flush_all ()
let lprint_endline str = lprint_string (str ^ "\n"); flush_all ()
let verbose str =
if !ApiConf.verbose
then output_string !ApiConf.verbose_output (str ^ "\n")
(* ************************************************************************** *)
(* Dump results in a human readable format *)
(* ************************************************************************** *)
let available_languages () =
lprint_string " Available languages: ";
lprint_endline (String.concat ", " ApiTypes.Lang.list)
let error e =
let open ApiError in
lprint_endline "[Error]";
lprint_endline (" Message: " ^ e.message);
lprint_endline (" Type: " ^ e.stype);
lprint_endline (" Code: " ^ (string_of_int e.code))
let page l f =
lprint_endline "[Page]";
lprint_endline (" Total items (server_size): " ^
(string_of_int l.ApiTypes.Page.server_size));
lprint_endline (" Index: " ^
(string_of_int l.ApiTypes.Page.index));
lprint_endline (" Limit: " ^
(string_of_int l.ApiTypes.Page.limit));
lprint_endline " Items:";
if List.length l.ApiTypes.Page.items = 0
then lprint_endline " Empty page"
else List.iter f l.ApiTypes.Page.items
let print a =
lprint_endline (ExtLib.dump a)