Changeset 17 in code for trunk/cli/last.ml


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

New subcommand 'recent'. Tidy last.ml

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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"
Note: See TracChangeset for help on using the changeset viewer.