Update changelog
[pkg-ocaml-js-of-ocaml.git] / tools / check_version.ml
blobac8d64605d98e5c090a37a0f26145bd6c2cf0813
1 open Pervasives
3 let parse_version s =
4 let rec aux s =
5 try
6 let (i,rest) = Scanf.sscanf s ".%i%s" (fun i s -> i,s) in
7 i::(aux rest)
8 with
9 | _ -> []
11 let (major,minor) = Scanf.sscanf s " %i%s" (fun i s -> i,s) in
12 major::(aux minor)
14 let rec get_version_line () =
15 let s = Pervasives.input_line Pervasives.stdin in
16 try
17 Scanf.sscanf s "version: %s" parse_version
18 with
19 | _ -> get_version_line ()
21 let check () =
22 let version_to_match = parse_version (Sys.argv.(1)) in
23 try
24 if version_to_match <= get_version_line ()
25 then exit 1
26 else exit 0
27 with
28 | End_of_file ->
29 print_endline "malformed input: no version number";
30 exit 0
32 let () = check ()