source: code/trunk/lib/archive.ml@ 27

Last change on this file since 27 was 25, checked in by fox, 2 years ago

New edit <ID> command and updated readme

File size: 1.4 KB
RevLine 
[3]1let predicate fn opt = Option.(to_list @@ map fn opt)
[2]2
[3]3let authored query_string =
4 let q = Person.Set.of_query @@ String_set.query query_string in
5 fun n -> Person.Set.predicate q n.Text.authors
[2]6
[9]7let ided query_string =
8 fun n -> n.Text.id = query_string
9
[3]10let keyworded query_string =
11 let q = String_set.query query_string in
12 fun n -> String_set.(predicate q (Text.set "Keywords" n))
[2]13
[3]14let topics query_string =
15 let q = String_set.query query_string in
16 fun n -> String_set.(predicate q (Text.set "Topics" n))
[25]17
18let apply_sys_util env def_env r order_opt reverse_opt number_opt authors_opt topics_opt id_opt =
19 let predicates = if id_opt <> "" then [ ided id_opt ] else []
20 @ predicate authored authors_opt
21 @ predicate topics topics_opt in
22 let predicate text = List.fold_left (fun a e -> a && e text) true predicates in
23 let util = try Sys.getenv env with Not_found -> def_env in
24 let print_text acc (_t, fnames) = Printf.sprintf "%s %s" acc (List.hd fnames) in
25 let paths = match order_opt with
26 | false -> File_store.fold ~r ~predicate print_text ""
27 | true ->
28 let order = match reverse_opt with true -> File_store.newest | false -> File_store.oldest in
29 match number_opt with
30 | Some number -> File_store.fold ~r ~predicate ~order ~number print_text ""
31 | None -> File_store.fold ~r ~predicate ~order print_text ""
32 in if paths = "" then ()
33 else (ignore @@ Sys.command @@ Printf.sprintf "%s %s" util paths)
Note: See TracBrowser for help on using the repository browser.