18 lines
779 B
OCaml
18 lines
779 B
OCaml
|
open Logarion
|
||
|
let authors r topics_opt =
|
||
|
let predicates = Archive.(predicate topics topics_opt) in
|
||
|
let predicate text = List.fold_left (fun a e -> a && e text) true predicates in
|
||
|
let author_union a (e, _) = Person.Set.union a e.Text.authors in
|
||
|
let s = File_store.fold ~r ~predicate author_union Person.Set.empty in
|
||
|
Person.Set.iter (fun x -> print_endline (Person.to_string x)) s
|
||
|
|
||
|
open Cmdliner
|
||
|
let term =
|
||
|
let recurse = Arg.(value & flag & info ["R"]
|
||
|
~doc:"include texts in subdirectories too") in
|
||
|
let topics = Arg.(value & opt (some string) None & info ["topics"]
|
||
|
~docv:"TOPICS" ~doc:"display authors who have written on topics") in
|
||
|
Term.(const authors $ recurse $ topics),
|
||
|
Term.info "authors" ~doc:"list authors"
|
||
|
~man:[ `S "DESCRIPTION"; `P "List author names" ]
|