Changeset 9 in code
- Timestamp:
- Jun 19, 2022, 9:01:11 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/dune
r6 r9 2 2 (name txt) 3 3 (public_name txt) 4 (modules txt authors convert conversion file index last listing new topics html atom gemini publish pull )4 (modules txt authors convert conversion file index last listing new topics html atom gemini publish pull read) 5 5 (libraries text_parse.converter text_parse.parsers logarion msgpck curl str cmdliner)) -
trunk/cli/listing.ml
r3 r9 2 2 module FS = File_store 3 3 module A = Archive 4 let listing r order_opt reverse_opt number_opt authors_opt topics_opt = 5 let predicates = A.predicate A.authored authors_opt 6 4 5 let listing r order_opt reverse_opt number_opt paths_opt authors_opt topics_opt = 6 let predicates = A.predicate A.authored authors_opt @ A.predicate A.topics topics_opt in 7 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"8 let list_text (t, fnames) = Printf.printf "%s %s %s 𐄁 %s%s\n" 9 9 (Text.short_id t) Date.(pretty_date @@ listing t.Text.date) 10 10 (Person.Set.to_string ~names_only:true t.Text.authors) 11 t.Text.title ( List.hd fnames)11 t.Text.title (if paths_opt then (List.fold_left (Printf.sprintf "%s\n@ %s") "" fnames) else "") 12 12 in 13 print_string @@match order_opt with14 | false -> FS. fold ~r ~predicate list_text ""13 match order_opt with 14 | false -> FS.iter ~r ~predicate list_text 15 15 | true -> 16 16 let order = match reverse_opt with true -> FS.newest | false -> FS.oldest in 17 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 ""18 | Some number -> FS.iter ~r ~predicate ~order ~number list_text 19 | None -> FS.iter ~r ~predicate ~order list_text 20 20 21 21 open Cmdliner 22 22 let 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 23 let recurse = Arg.(value & flag & info ["R"] ~doc:"recurse, include subdirs") in 24 let reverse = Arg.(value & flag & info ["r"] ~doc:"reverse order") in 25 let time = Arg.(value & flag & info ["t"] ~doc:"sort by time, newest first") in 26 let paths = Arg.(value & flag & info ["p"] ~doc:"show file paths") in 29 27 let number = Arg.(value & opt (some int) None & info ["n"] 30 28 ~docv:"number" ~doc:"number of entries to list") in … … 33 31 let topics = Arg.(value & opt (some string) None & info ["topics"] 34 32 ~docv:"comma-separated topics" ~doc:"texts with topics") in 35 Term.(const listing $ recurse $ time $ reverse $ number $ authed $ topics),33 Term.(const listing $ recurse $ time $ reverse $ number $ paths $ authed $ topics), 36 34 Term.info "list" ~doc:"list texts" ~man:[ `S "DESCRIPTION"; 37 `P "List header information for current directory. If -R is used, list header38 information for texts found in subdirectories too, along with their filepaths" ]35 `P "List header information for current directory. If -R is used, list header 36 information for texts found in subdirectories too, along with their filepaths" ] -
trunk/cli/txt.ml
r6 r9 17 17 Publish.term; 18 18 Pull.term; 19 Read.term; 19 20 Topics.term; 20 21 ] with `Error _ -> exit 1 | _ -> exit 0 -
trunk/lib/archive.ml
r3 r9 4 4 let q = Person.Set.of_query @@ String_set.query query_string in 5 5 fun n -> Person.Set.predicate q n.Text.authors 6 7 let ided query_string = 8 fun n -> n.Text.id = query_string 6 9 7 10 let keyworded query_string =
Note:
See TracChangeset
for help on using the changeset viewer.