-
Notifications
You must be signed in to change notification settings - Fork 0
/
dostay.ml
36 lines (29 loc) · 1 KB
/
dostay.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
open Common
open Getopt
let prefix' = ref "stay"
let outdir' = ref (Some !prefix')
let mark' = ref ""
let specs =
[
(noshort,"prefix",None,Some (fun x -> prefix' := x));
(noshort,"outdir",None,Some (fun x -> outdir' := Some x));
(noshort,"nodir", (set outdir' None), None);
('k',"mark",None,Some (fun x -> mark' := x))
]
let () =
let args = getOptArgs specs in
let prefix, outdir, mark =
!prefix', !outdir', !mark' in
let bucksName,outdir =
match args with
| bucksName::outdir::restArgs -> bucksName,Some outdir
| bucksName::restArgs -> bucksName,outdir
| _ -> failwith "usage: dostay bucksName [outdir]"
in
let baseName = cutPathZ bucksName in
let saveName = sprintf "%s-%s%s" prefix mark baseName |> mayPrependDir outdir in
leprintfln "reading bucks from %s, storing stays in %s" bucksName saveName;
let bucks: day_buckets = loadData bucksName in
let stays: staying = Bucket_power.staying bucks in
mayMkDir outdir;
saveData stays saveName