logarion/cli/topics.ml

18 lines
749 B
OCaml
Raw Normal View History

open Logarion
let topics r authors_opt =
let predicates = Archive.(predicate authored authors_opt) in
let predicate text = List.fold_left (fun a e -> a && e text) true predicates in
let topic_union a (e, _) = String_set.union a (Text.set "topics" e) in
let s = File_store.fold ~r ~predicate topic_union String_set.empty in
print_endline @@ String_set.to_string s
open Cmdliner
let term =
let recurse = Arg.(value & flag & info ["R"]
~doc:"include texts in subdirectories") in
let authed = Arg.(value & opt (some string) None & info ["authored"]
~docv:"comma-separated authors" ~doc:"topics by authors") in
Term.(const topics $ recurse $ authed),
Term.info "topics" ~doc:"list topics" ~man:[ `S "DESCRIPTION";
`P "List of topics" ]