summaryrefslogtreecommitdiff
path: root/ocaml/scripts/process_pill.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml/scripts/process_pill.ml')
-rw-r--r--ocaml/scripts/process_pill.ml27
1 files changed, 27 insertions, 0 deletions
diff --git a/ocaml/scripts/process_pill.ml b/ocaml/scripts/process_pill.ml
new file mode 100644
index 0000000..c02f6ed
--- /dev/null
+++ b/ocaml/scripts/process_pill.ml
@@ -0,0 +1,27 @@
+open Nock_lib
+
+let read_bytes path =
+ let ic = open_in_bin path in
+ let len = in_channel_length ic in
+ let data = really_input_string ic len in
+ close_in ic;
+ Bytes.of_string data
+
+let describe_root noun =
+ match noun with
+ | Noun.Cell (tag, _) ->
+ begin match tag with
+ | Noun.Atom z -> Printf.printf "tag=%s\n" (Z.to_string z)
+ | _ -> Printf.printf "tag=cell\n"
+ end
+ | Noun.Atom _ -> Printf.printf "atom pill\n"
+
+let () =
+ if Array.length Sys.argv < 2 then begin
+ prerr_endline "usage: process_pill path";
+ exit 1
+ end;
+ let path = Sys.argv.(1) in
+ let bytes = read_bytes path in
+ let noun = Serial.cue bytes in
+ describe_root noun