Changeset 17 in code for trunk


Ignore:
Timestamp:
Oct 21, 2022, 7:53:46 PM (3 years ago)
Author:
fox
Message:

New subcommand 'recent'. Tidy last.ml

Location:
trunk/cli
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/dune

    r9 r17  
    22 (name txt)
    33 (public_name txt)
    4  (modules txt authors convert conversion file index last listing new topics html atom gemini publish pull read)
     4 (modules txt authors convert conversion file index last listing new topics html atom gemini publish pull read recent)
    55 (libraries text_parse.converter text_parse.parsers logarion msgpck curl str cmdliner))
  • trunk/cli/last.ml

    r3 r17  
    11open Logarion
     2
     3let last a ((t,_) as pair) = match a with
     4        | None -> Some pair
     5        | Some (t', _) as pair' ->
     6                if Text.newest t t' > 0 then Some pair else pair'
     7
     8let last_mine a ((t, _) as pair) =
     9        let name = Person.Set.of_string (Sys.getenv "USER") in
     10        let open Text in
     11        match a with
     12        | None -> if Person.Set.subset name t.authors then Some pair else None
     13        | Some (t', _) as pair' ->
     14                if Text.newest t t' > 0 && Person.Set.subset name t'.authors
     15                then Some pair else pair'
     16
    217let last search_mine =
    3         let last a ((t,_) as pair) = match a with None -> Some pair
    4                 | Some (t', _) as pair' -> if Text.newest t t' > 0
    5                         then Some pair else pair' in
    6         let last_mine a ((t,_) as pair) =
    7                 let name = Person.Set.of_string (Sys.getenv "USER") in
    8                 let open Text in
    9                 match a with
    10                 | None -> if Person.Set.subset name t.authors then Some pair else None
    11                 | Some (t', _) as pair' ->
    12                         if Text.newest t t' > 0 && Person.Set.subset name t'.authors
    13                         then Some pair else pair'
    14         in
    15         match File_store.fold (if search_mine then last_mine else last) None with
    16         | Some (_,f) -> List.iter print_endline f | None -> ()
     18        let filter = if search_mine then last_mine else last in
     19        match File_store.fold filter None with
     20        | None -> ()
     21        | Some (_, f) -> List.iter print_endline f
    1722
    1823open Cmdliner
    1924let term =
    20         let mine = Arg.(value & flag & info ["mine"]
    21                 ~doc:"last text authored by me") in
     25        let mine = Arg.(value & flag & info ["mine"] ~doc:"last text authored by me") in
    2226        Term.(const last $ mine),
    2327        Term.info "last" ~doc:"most recent text"
  • trunk/cli/txt.ml

    r9 r17  
    1818        Pull.term;
    1919        Read.term;
     20        Recent.term;
    2021        Topics.term;
    2122        ] with `Error _ -> exit 1 | _ -> exit 0
Note: See TracChangeset for help on using the changeset viewer.