source: code/trunk/cli/last.ml@ 32

Last change on this file since 32 was 17, checked in by fox, 3 years ago

New subcommand 'recent'. Tidy last.ml

File size: 902 bytes
Line 
1open 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
17let last search_mine =
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
22
23open Cmdliner
24let term =
25 let mine = Arg.(value & flag & info ["mine"] ~doc:"last text authored by me") in
26 Term.(const last $ mine),
27 Term.info "last" ~doc:"most recent text"
28 ~man:[ `S "DESCRIPTION"; `P "Print the filename of most recent text" ]
Note: See TracBrowser for help on using the repository browser.