forked from Incubaid/rsync-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
syncer.ml
42 lines (37 loc) · 926 Bytes
/
syncer.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
type command =
| Help
| Signature
| Test
open Signature
module MySig = Signature(Adler) (Hash.SDigest)
let calculate_signature fn sig_fn =
let bs = MySig.optimal fn in
let s = MySig.create fn bs in
let oc = open_out sig_fn in
MySig.output_signature oc s;
close_out oc
let _ =
let fn = ref "" in
let signature = ref "" in
let command = ref Help in
let usage = "___usage___" in
let speclist = [
("--signature",
Arg.Tuple [
Arg.Unit (fun () -> command := Signature);
Arg.Set_string fn;
Arg.Set_string signature;
], "<input> <sig> : generate a signature file");
("--test",
Arg.Unit (fun () -> command := Test), "run tests");
]
in
let () = Arg.parse
speclist
(fun s -> fn := s)
usage
in
match !command with
| Help -> Arg.usage speclist usage
| Signature -> calculate_signature !fn !signature
| Test -> Test.suite ()