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

Last change on this file since 72 was 69, checked in by Izuru Yakumo, 8 months ago

txt new no longer sets default titles, remove %%VERSION%% from all subcommands (as they're pulled from txt.ml)

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

File size: 995 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
24
25let mine = Arg.(value & flag & info ["mine"] ~doc: "Last text authored by me")
26let last_t = Term.(const last $ mine)
27
28let cmd =
29 let doc = "Most recent text" in
30 let man = [
31 `S Manpage.s_description;
32 `P "Print the filename of most recent text" ]
33 in
34 let info = Cmd.info "last" ~doc ~man in
35 Cmd.v info last_t
Note: See TracBrowser for help on using the repository browser.