source: code/trunk/cli/listing.ml@ 5

Last change on this file since 5 was 3, checked in by fox, 3 years ago
  • Removed 'txt init'

Format

  • New B32 ID

Index

  • New option: txt index --print
  • Move scheme to peers
  • Replace peer.*.conf files with index packed locations Instead of adding a URL to peers.*.conf, run txt pull <url>

Conversion

  • Rewritten converters
  • txt-convert looks for a .convert.conf containing key: value lines.
  • Specifiable topic-roots from .convert.conf.
  • Added Topics: key, with comma seperated topics.

If set only those topics will appear in the main index and used as topic roots.
Other topics will have sub-indices generated, but won't be listed in the main index.

  • HTML converter header & footer options
  • HTML-index renamed to HTM-index

Internal

  • Change types: uuid:Uuid -> id:string
  • File_store merges identical texts
  • Use peer ID for store path, store peers' texts in .local/share/texts
  • Simple URN resolution for converter

Continue to next feed if parsing one fails

  • Phasing-out Archive, replaced by improved packs
  • Eliminate Bos, Cohttp, lwt, uri, tls, Re, Ptime, dependencies
  • Lock version for Cmdliner, fix dune-project
  • Optional resursive store
  • Improve header_pack
  • Fix recursive mkdir
File size: 1.8 KB
RevLine 
[3]1open Logarion
2module FS = File_store
3module A = Archive
4let listing r order_opt reverse_opt number_opt authors_opt topics_opt =
5 let predicates = A.predicate A.authored authors_opt
6 @ A.predicate A.topics topics_opt in
7 let predicate text = List.fold_left (fun a e -> a && e text) true predicates in
8 let list_text a (t, fnames) = a ^ Printf.sprintf "%s %s %s 𐄁 %s [%s]\n"
9 (Text.short_id t) Date.(pretty_date @@ listing t.Text.date)
10 (Person.Set.to_string ~names_only:true t.Text.authors)
11 t.Text.title (List.hd fnames)
12 in
13 print_string @@ match order_opt with
14 | false -> FS.fold ~r ~predicate list_text ""
15 | true ->
16 let order = match reverse_opt with true -> FS.newest | false -> FS.oldest in
17 match number_opt with
18 | Some number -> FS.fold ~r ~predicate ~order ~number list_text ""
19 | None -> FS.fold ~r ~predicate ~order list_text ""
20
21open Cmdliner
22let term =
23 let recurse = Arg.(value & flag & info ["R"]
24 ~doc:"recursive, include texts in subdirectories too") in
25 let reverse = Arg.(value & flag & info ["r"]
26 ~doc:"reverse order") in
27 let time = Arg.(value & flag & info ["t"]
28 ~doc:"Sort by time, newest first") in
29 let number = Arg.(value & opt (some int) None & info ["n"]
30 ~docv:"number" ~doc:"number of entries to list") in
31 let authed = Arg.(value & opt (some string) None & info ["authored"]
32 ~docv:"comma-separated names" ~doc:"texts by authors") in
33 let topics = Arg.(value & opt (some string) None & info ["topics"]
34 ~docv:"comma-separated topics" ~doc:"texts with topics") in
35 Term.(const listing $ recurse $ time $ reverse $ number $ authed $ topics),
36 Term.info "list" ~doc:"list texts" ~man:[ `S "DESCRIPTION";
37 `P "List header information for current directory. If -R is used, list header
38 information for texts found in subdirectories too, along with their filepaths" ]
Note: See TracBrowser for help on using the repository browser.