List file names and new fox pts/0 192.168.88.21 Sat Jun 19 16:14 still logged in
fox pts/0 192.168.88.21 Fri Jun 18 15:03 - 15:07 (00:04) fox pts/0 192.168.88.21 Fri Jun 18 13:09 - 13:15 (00:05) fox pts/0 192.168.88.21 Thu Jun 17 22:08 - 00:23 (02:15) fox pts/0 192.168.88.21 Thu Jun 17 11:15 - 15:59 (04:44) fox pts/0 192.168.88.21 Wed Jun 16 09:30 - 20:51 (11:21) fox pts/0 192.168.88.21 Tue Jun 15 22:33 - 23:37 (01:04) fox pts/0 192.168.88.21 Tue Jun 15 11:38 - 13:13 (01:35) fox pts/0 192.168.88.21 Mon Jun 14 21:07 - 21:09 (00:01) fox pts/0 192.168.88.21 Mon Jun 14 09:11 - 19:43 (10:31) fox pts/0 192.168.88.21 Sun Jun 13 17:15 - 17:53 (00:38) fox pts/0 192.168.88.21 Sun Jun 13 09:45 - 15:43 (05:57) fox pts/0 192.168.88.21 Sat Jun 12 15:59 - 17:51 (01:51) fox pts/0 192.168.88.21 Fri Jun 11 18:59 - 19:40 (00:41) fox pts/0 192.168.88.21 Fri Jun 11 12:52 - 16:53 (04:00) fox pts/0 192.168.88.21 Wed Jun 9 09:15 - 09:56 (00:40) fox pts/0 192.168.88.21 Tue Jun 8 18:35 - 18:37 (00:01) fox pts/0 192.168.88.21 Tue Jun 8 17:32 - 17:44 (00:11) fox pts/0 192.168.88.21 Tue Jun 8 09:38 - 13:44 (04:06) fox pts/0 192.168.88.21 Mon Jun 7 20:41 - 21:59 (01:18) fox pts/0 192.168.88.21 Mon Jun 7 14:49 - 14:52 (00:02) fox pts/0 192.168.88.21 Mon Jun 7 11:15 - 14:49 (03:33) fox pts/0 192.168.88.5 Sun Jun 6 11:07 - 15:53 (04:46) fox pts/0 192.168.88.5 Sat Jun 5 21:36 - 00:19 (02:43) fox pts/0 192.168.88.5 Sat Jun 5 17:48 - 19:42 (01:54) fox pts/0 192.168.88.21 Fri Jun 4 20:01 - 20:05 (00:03) fox pts/0 192.168.88.21 Fri Jun 4 18:39 - 18:40 (00:01) fox pts/0 192.168.88.21 Fri Jun 4 10:09 - 11:26 (01:17) fox pts/0 192.168.88.21 Thu Jun 3 18:50 - 23:05 (04:14) fox pts/0 192.168.88.21 Tue Jun 1 09:31 - 12:28 (02:57) fox pts/0 192.168.88.21 Mon May 31 09:31 - 17:31 (08:00) fox pts/0 192.168.88.21 Sun May 30 21:32 - 00:28 (02:56) fox pts/0 192.168.88.21 Sat May 29 11:26 - 12:07 (00:41) fox pts/0 192.168.88.21 Fri May 28 18:22 - 21:27 (03:04) fox pts/0 192.168.88.21 Tue May 25 10:44 - 11:42 (00:57) fox pts/0 192.168.88.21 Sat May 22 14:23 - 21:06 (06:42) fox pts/0 192.168.88.21 Thu May 20 12:21 - 13:08 (00:47) fox pts/0 192.168.88.21 Wed May 19 23:04 - 23:10 (00:05) fox pts/0 192.168.88.21 Mon May 17 22:16 - 23:48 (01:32) fox pts/0 192.168.88.21 Mon May 17 18:24 - 20:31 (02:07) fox pts/0 192.168.88.5 Mon May 17 11:04 - 11:34 (00:30) fox pts/0 192.168.88.21 Sat May 15 13:08 - 14:24 (01:15) fox pts/0 192.168.88.21 Fri May 14 22:22 - 22:23 (00:00) fox pts/0 192.168.88.21 Fri May 14 22:15 - 22:22 (00:06) fox pts/0 192.168.88.21 Fri May 14 18:08 - 19:01 (00:53) fox pts/0 192.168.88.21 Fri May 14 15:44 - 15:45 (00:00) fox pts/0 192.168.88.21 Fri May 14 15:44 - 15:44 (00:00) fox pts/0 192.168.88.21 Thu May 13 23:27 - 23:36 (00:09) fox pts/0 192.168.88.21 Fri May 7 18:19 - 21:27 (03:07) fox pts/0 192.168.88.21 Fri May 7 10:28 - 14:58 (04:29) fox pts/0 192.168.88.21 Tue May 4 20:19 - 20:25 (00:06) fox pts/0 192.168.88.5 Fri Apr 30 13:04 - 15:06 (02:01) fox pts/0 192.168.88.5 Tue Apr 27 13:05 - 19:15 (06:10) fox pts/0 192.168.88.5 Sun Apr 25 11:19 - 12:05 (00:45) fox pts/0 192.168.88.21 Fri Apr 23 12:39 - 14:57 (02:17) fox pts/0 192.168.88.21 Tue Apr 20 12:57 - 13:39 (00:41) fox pts/0 192.168.88.5 Tue Apr 20 10:20 - 11:47 (01:26) fox pts/0 192.168.88.5 Mon Apr 19 19:26 - 21:18 (01:52) fox pts/0 192.168.88.5 Sun Apr 18 22:02 - 02:13 (04:11) fox pts/0 192.168.88.5 Sun Apr 18 10:52 - 13:42 (02:50) fox pts/0 192.168.88.5 Sat Apr 17 17:52 - 17:56 (00:04) fox pts/0 192.168.88.21 Fri Apr 16 23:37 - 23:41 (00:03) reboot system boot 5.11.2-1-ARCH Thu Jan 1 01:00 still running fox pts/0 192.168.88.21 Fri Apr 16 22:10 - 22:50 (00:40) fox pts/0 192.168.88.21 Fri Apr 16 13:47 - 14:32 (00:44) fox pts/0 192.168.88.5 Fri Apr 16 13:19 - 13:25 (00:06) fox pts/0 192.168.88.5 Fri Apr 16 10:03 - 10:54 (00:51) fox pts/0 192.168.88.21 Mon Apr 12 22:05 - 01:32 (03:26) fox pts/0 192.168.88.5 Fri Apr 9 11:13 - 18:39 (1+07:25) fox pts/0 192.168.88.21 Wed Apr 7 18:51 - 19:15 (00:23) fox pts/0 192.168.88.21 Tue Apr 6 22:54 - 23:26 (00:32) fox pts/0 192.168.88.21 Fri Apr 2 19:22 - 01:16 (05:54) fox pts/0 192.168.88.21 Fri Apr 2 13:54 - 18:00 (04:05) fox pts/0 192.168.88.21 Thu Apr 1 09:25 - 16:00 (06:35) fox pts/0 192.168.88.21 Wed Mar 31 11:10 - 22:22 (11:11) fox pts/0 192.168.88.21 Wed Mar 31 00:14 - 00:15 (00:01) fox pts/0 192.168.88.21 Tue Mar 30 21:44 - 00:07 (02:22) fox pts/0 192.168.88.21 Tue Mar 30 14:04 - 14:44 (00:39) fox pts/0 192.168.88.21 Wed Mar 24 20:36 - 22:06 (01:29) fox pts/0 192.168.88.21 Wed Mar 24 09:17 - 09:25 (00:08) fox pts/0 192.168.88.21 Tue Mar 16 13:26 - 13:33 (00:07) fox pts/0 192.168.88.21 Mon Mar 15 15:56 - 15:58 (00:01) fox pts/0 192.168.88.21 Sun Mar 14 13:06 - 17:48 (04:42) reboot system boot 5.11.2-1-ARCH Thu Jan 1 01:00 - 22:52 (18733+21:51) fox pts/0 192.168.88.21 Sun Mar 14 11:31 - 13:01 (01:29) fox pts/0 192.168.88.21 Sat Mar 13 12:11 - 18:54 (06:42) fox pts/0 192.168.88.21 Fri Mar 12 21:58 - 00:18 (02:19) fox pts/0 192.168.88.21 Thu Mar 11 15:56 - 23:13 (07:17) fox pts/0 192.168.88.21 Tue Mar 9 21:30 - 00:37 (03:06) fox pts/0 192.168.88.21 Tue Mar 9 16:21 - 16:22 (00:00) fox pts/0 192.168.88.21 Mon Mar 8 12:46 - 13:15 (00:29) fox pts/0 192.168.88.21 Sun Mar 7 17:53 - 17:55 (00:02) fox pts/0 192.168.88.21 Sun Mar 7 16:19 - 16:31 (00:11) fox pts/0 192.168.88.21 Sun Mar 7 16:11 - 16:12 (00:00) fox pts/0 192.168.88.21 Sun Mar 7 16:00 - 16:05 (00:05) fox pts/0 192.168.88.21 Sun Mar 7 09:39 - 16:00 (06:20) fox pts/0 192.168.88.21 Sat Mar 6 15:33 - 21:53 (06:20) fox pts/0 192.168.88.21 Sat Mar 6 13:03 - 14:40 (01:36) fox pts/0 192.168.88.21 Fri Mar 5 19:13 - 01:10 (05:56) fox pts/0 192.168.88.21 Thu Mar 4 17:22 - 19:55 (02:32) fox pts/0 192.168.88.21 Wed Mar 3 11:58 - 23:47 (11:48) fox pts/0 192.168.88.21 Tue Mar 2 19:21 - 00:22 (05:00) fox pts/0 192.168.88.21 Tue Mar 2 13:30 - 16:34 (03:04) fox pts/0 192.168.88.21 Mon Mar 1 23:04 - 23:38 (00:33) fox pts/0 192.168.88.21 Mon Mar 1 17:21 - 20:41 (03:19) fox pts/0 192.168.88.21 Sun Feb 28 19:53 - 20:24 (00:31) fox pts/0 192.168.88.21 Sun Feb 28 17:15 - 19:41 (02:26) fox pts/0 192.168.88.21 Sun Feb 28 14:40 - 14:51 (00:10) fox pts/0 192.168.88.21 Thu Feb 25 21:44 - 00:02 (02:17) fox pts/0 192.168.88.21 Wed Feb 24 10:38 - 11:42 (01:03) reboot system boot 5.11.0-2-ARCH Thu Jan 1 01:00 - 13:02 (18700+13:02) fox pts/0 192.168.88.21 Wed Feb 24 09:55 - 10:36 (00:40) fox pts/0 192.168.88.21 Mon Feb 22 16:53 - 23:53 (07:00) fox pts/0 192.168.88.21 Mon Feb 22 12:10 - 14:22 (02:11) fox pts/0 192.168.88.21 Sun Feb 21 15:50 - 21:20 (05:29) fox pts/0 192.168.88.21 Sun Feb 21 09:41 - 10:51 (01:10) fox pts/0 192.168.88.21 Sat Feb 20 21:10 - 21:13 (00:02) fox pts/0 192.168.88.21 Sat Feb 20 14:04 - 21:10 (07:05) fox pts/0 192.168.88.21 Fri Feb 19 09:38 - 17:08 (07:29) fox pts/0 192.168.88.21 Thu Feb 18 23:05 - 00:54 (01:48) fox pts/0 192.168.88.21 Wed Feb 17 08:38 - 16:46 (08:07) fox pts/0 192.168.88.21 Mon Feb 15 22:52 - 23:36 (00:44) fox pts/0 192.168.88.21 Mon Feb 15 13:54 - 20:37 (06:43) fox pts/0 192.168.88.21 Sun Feb 14 09:16 - 16:11 (06:55) fox pts/0 192.168.88.21 Sat Feb 13 08:58 - 00:52 (15:54) fox pts/0 192.168.88.21 Fri Feb 12 16:33 - 21:56 (05:23) fox pts/0 192.168.88.21 Fri Feb 12 11:17 - 14:11 (02:53) fox pts/0 192.168.88.21 Wed Feb 10 10:17 - 13:37 (03:20) fox pts/0 192.168.88.21 Tue Feb 9 09:54 - 23:35 (13:40) fox pts/0 192.168.88.21 Sun Feb 7 09:45 - 20:50 (11:05) fox pts/0 192.168.88.21 Sat Feb 6 19:32 - 00:12 (04:39) fox pts/0 192.168.88.21 Sat Feb 6 11:35 - 18:41 (07:06) fox pts/0 192.168.88.21 Fri Feb 5 23:02 - 23:13 (00:11) fox pts/0 192.168.88.21 Wed Feb 3 19:04 - 23:42 (04:38) fox pts/0 192.168.88.21 Tue Feb 2 10:11 - 01:01 (14:50) fox pts/0 192.168.88.21 Mon Feb 1 18:38 - 21:13 (02:35) fox pts/5 192.168.88.5 Mon Feb 1 10:30 - 11:12 (00:41) fox pts/0 192.168.88.21 Mon Feb 1 10:03 - 10:45 (00:41) fox pts/0 192.168.88.5 Sun Jan 31 16:37 - 19:36 (02:59) fox pts/0 192.168.88.21 Sat Jan 30 10:02 - 20:55 (10:52) fox pts/0 192.168.88.21 Thu Jan 28 17:13 - 19:55 (02:41) fox pts/0 192.168.88.21 Sun Jan 24 16:34 - 01:57 (09:22) fox pts/0 192.168.88.21 Sun Jan 24 14:14 - 15:41 (01:26) fox pts/0 192.168.88.21 Thu Jan 21 09:49 - 21:04 (11:14) fox pts/0 192.168.88.21 Wed Jan 20 21:59 - 00:14 (02:14) fox pts/0 192.168.88.21 Mon Jan 18 21:42 - 22:34 (00:51) fox pts/0 192.168.88.21 Sun Jan 17 17:26 - 19:22 (01:56) fox pts/0 192.168.88.21 Fri Jan 15 18:09 - 18:10 (00:00) fox pts/0 192.168.88.5 Tue Jan 12 21:48 - 23:22 (01:34) fox pts/0 192.168.88.21 Sun Jan 10 10:42 - 13:45 (03:02) fox pts/0 192.168.88.5 Sat Jan 9 19:19 - 22:00 (02:40) fox pts/0 192.168.88.21 Sat Jan 9 16:43 - 17:14 (00:30) fox pts/0 192.168.88.5 Fri Jan 8 21:13 - 22:33 (01:19) fox pts/0 192.168.88.5 Thu Jan 7 22:50 - 00:34 (01:44) fox pts/0 192.168.88.5 Mon Jan 4 21:45 - 02:18 (04:32) fox pts/0 192.168.88.21 Mon Jan 4 10:00 - 18:18 (08:17) fox pts/5 192.168.88.5 Sun Jan 3 13:33 - 15:06 (01:33) fox pts/5 192.168.88.5 Sun Jan 3 13:31 - 13:32 (00:01) fox pts/5 192.168.88.5 Sun Jan 3 13:28 - 13:31 (00:02) fox pts/0 192.168.88.21 Sun Jan 3 09:45 - 13:42 (03:57) fox pts/0 192.168.88.5 Sat Jan 2 22:45 - 00:25 (01:39) fox pts/0 192.168.88.21 Sat Jan 2 14:34 - 20:40 (06:06) fox pts/0 192.168.88.21 Thu Dec 31 09:39 - 16:34 (06:54) fox pts/0 192.168.88.21 Wed Dec 30 21:31 - 23:33 (02:02) fox pts/0 192.168.88.21 Tue Dec 29 21:15 - 23:16 (02:01) fox pts/0 192.168.88.21 Tue Dec 29 19:16 - 20:33 (01:16) fox pts/0 192.168.88.21 Mon Dec 28 17:56 - 23:03 (05:06) fox pts/0 192.168.88.21 Sun Dec 27 23:01 - 00:39 (01:37) fox pts/0 192.168.88.21 Sun Dec 27 14:18 - 14:38 (00:20) fox pts/0 192.168.88.21 Sun Dec 27 09:58 - 12:34 (02:35) root pts/1 tmux(4435).%0 Sat Dec 26 21:13 - 21:15 (00:01) fox pts/0 192.168.88.21 Sat Dec 26 20:45 - 23:39 (02:54) reboot system boot 5.8.9-1-ARCH Thu Jan 1 01:00 - 10:37 (18682+10:37) root pts/1 tmux(9747).%0 Sat Dec 26 19:20 - 20:02 (00:42) fox pts/0 192.168.88.21 Sat Dec 26 19:17 - 20:02 (00:44) fox pts/0 192.168.88.21 Sat Dec 26 19:16 - 19:17 (00:00) fox pts/0 192.168.88.21 Sat Dec 26 15:07 - 17:49 (02:41) fox pts/0 192.168.88.21 Wed Dec 23 18:16 - 20:56 (02:39) fox pts/0 192.168.88.21 Wed Dec 23 13:49 - 18:16 (04:26) fox pts/0 192.168.88.5 Mon Dec 14 20:50 - 20:52 (00:02) fox pts/0 192.168.88.5 Wed Dec 9 21:45 - 22:52 (01:06) fox pts/0 192.168.88.5 Mon Dec 7 13:21 - 13:36 (00:15) fox pts/0 192.168.88.5 Sat Dec 5 15:42 - 16:06 (00:23) fox pts/0 192.168.88.5 Mon Nov 23 17:35 - 17:35 (00:00) fox pts/0 192.168.88.5 Sun Nov 22 10:45 - 17:36 (06:50) fox pts/0 192.168.88.5 Thu Nov 19 21:41 - 23:32 (01:50) fox pts/5 192.168.88.5 Thu Nov 19 15:08 - 15:35 (00:26) fox pts/0 192.168.88.5 Thu Nov 19 14:46 - 15:19 (00:33) fox pts/0 192.168.88.5 Wed Nov 18 13:41 - 15:20 (01:38) fox pts/0 192.168.88.5 Mon Nov 16 16:56 - 20:27 (03:31) fox pts/0 192.168.88.5 Sat Nov 14 14:44 - 15:57 (01:12) fox pts/0 192.168.88.5 Sat Nov 14 09:37 - 10:14 (00:37) fox pts/0 192.168.88.5 Fri Nov 13 22:09 - 00:10 (02:00) fox pts/0 192.168.88.5 Fri Nov 13 21:54 - 22:09 (00:14) fox pts/0 192.168.88.5 Wed Nov 11 22:48 - 23:01 (00:13) fox pts/0 192.168.88.5 Wed Nov 11 20:56 - 21:26 (00:29) fox pts/0 192.168.88.5 Tue Nov 10 16:55 - 16:55 (00:00) fox pts/0 192.168.88.5 Mon Nov 9 21:28 - 21:35 (00:07) fox pts/0 192.168.88.5 Mon Nov 9 14:24 - 14:24 (00:00) fox pts/0 192.168.88.5 Sun Nov 8 13:36 - 13:38 (00:02) fox pts/0 192.168.88.5 Sun Nov 8 13:00 - 13:10 (00:09) fox pts/0 192.168.88.5 Sat Nov 7 12:59 - 13:27 (00:27) fox pts/0 192.168.88.5 Thu Nov 5 21:34 - 00:51 (03:16) fox pts/0 192.168.88.5 Wed Nov 4 21:31 - 22:08 (00:36) fox pts/0 192.168.88.5 Wed Nov 4 17:44 - 20:31 (02:47) fox pts/0 192.168.88.5 Wed Nov 4 17:06 - 17:44 (00:37) fox pts/0 192.168.88.5 Tue Nov 3 22:43 - 23:57 (01:14) fox pts/0 192.168.88.5 Tue Nov 3 22:42 - 22:43 (00:00) fox pts/0 192.168.88.5 Tue Nov 3 09:25 - 09:32 (00:07) fox pts/0 192.168.88.5 Sun Oct 25 21:24 - 00:17 (02:52) fox pts/0 192.168.88.5 Sun Oct 25 10:55 - 13:32 (02:37) fox pts/0 192.168.88.5 Fri Oct 23 13:57 - 14:54 (00:56) wtmp begins Fri Oct 23 13:57:08 2020 subcommand
This commit is contained in:
parent
bf3c14f2d0
commit
6ba60d90cc
86
cli/cli.ml
86
cli/cli.ml
@ -5,48 +5,64 @@ open Logarion
|
||||
module A = Logarion.Archive.Make(File_store)
|
||||
|
||||
(* TODO: merge in lib/ so other modules can use (.e.g HTTP pull) *)
|
||||
let text_list field_opt authors_opt keywords_opt topics_opt =
|
||||
match A.of_path "." with
|
||||
| Error msg -> prerr_endline msg
|
||||
| Ok archive ->
|
||||
let predicates =
|
||||
A.predicate A.authored authors_opt
|
||||
@ A.predicate A.keyworded keywords_opt
|
||||
@ A.predicate A.topics topics_opt
|
||||
in
|
||||
let predicate text = List.fold_left (fun a e -> a && e text) true predicates in
|
||||
let order = A.newest in
|
||||
let print_fold ~predicate fn =
|
||||
let ts = A.fold ~predicate ~order fn String_set.empty archive in
|
||||
String_set.iter (print_endline) ts
|
||||
in
|
||||
match field_opt with
|
||||
| None -> A.iter ~predicate ~order (fun (n,_) -> print_endline n.Text.title) archive
|
||||
| Some "keywords"-> print_fold ~predicate (fun a (e,_) -> (String_set.union a (Text.set "keywords" e)))
|
||||
| Some "topics" -> print_fold ~predicate (fun a (e,_) -> (String_set.union a (Text.set "topics" e)))
|
||||
| Some "authors" ->
|
||||
let s = A.fold ~predicate ~order (fun a (e,_) -> Person.Set.union a e.Text.authors) Person.Set.empty archive in
|
||||
print_endline @@ Person.Set.to_string s
|
||||
| Some x -> prerr_endline @@ "Unrecognised field: " ^ x
|
||||
let text_list order_opt reverse_opt field_opt authors_opt keywords_opt topics_opt =
|
||||
match A.of_path (Sys.getcwd ()) with
|
||||
| Error msg -> prerr_endline msg
|
||||
| Ok archive ->
|
||||
let predicates =
|
||||
A.predicate A.authored authors_opt
|
||||
@ A.predicate A.keyworded keywords_opt
|
||||
@ A.predicate A.topics topics_opt
|
||||
in
|
||||
let predicate text = List.fold_left (fun a e -> a && e text) true predicates in
|
||||
let print_fold ~predicate fn =
|
||||
let ts = A.fold ~predicate fn String_set.empty archive in
|
||||
String_set.iter (print_endline) ts
|
||||
in
|
||||
let list_text (_t, fname) = print_endline fname in
|
||||
match field_opt with
|
||||
| Some "keywords"-> print_fold ~predicate (fun a (e,_) -> (String_set.union a (Text.set "keywords" e)))
|
||||
| Some "topics" -> print_fold ~predicate (fun a (e,_) -> (String_set.union a (Text.set "topics" e)))
|
||||
| Some "authors" ->
|
||||
let s = A.fold ~predicate (fun a (e,_) -> Person.Set.union a e.Text.authors) Person.Set.empty archive in
|
||||
print_endline @@ Person.Set.to_string s
|
||||
| Some x -> prerr_endline @@ "Unrecognised field: " ^ x
|
||||
| None -> match order_opt with false -> A.iter ~predicate list_text archive
|
||||
| true ->
|
||||
let order = match reverse_opt with true -> A.newest | false -> A.oldest in
|
||||
A.iter ~predicate ~order list_text archive
|
||||
|
||||
let list_term =
|
||||
let field = Arg.(value & opt (some string) None & info ["f"; "field"] ~docv:"FIELD" ~doc:"what to list") in
|
||||
let authors = Arg.(value & opt (some string) None & info ["a"; "authors"] ~docv:"AUTHORS" ~doc:"texts with authors") in
|
||||
let keywords= Arg.(value & opt (some string) None & info ["k"; "keywords"] ~docv:"KEYWORDS" ~doc:"texts with keywords") in
|
||||
let topics = Arg.(value & opt (some string) None & info ["t"; "topics"] ~docv:"TOPICS" ~doc:"texts with topics") in
|
||||
Term.(const text_list $ field $ authors $ keywords $ topics),
|
||||
Term.info "list" ~doc:"list texts" ~man:[ `S "DESCRIPTION"; `P "List texts" ]
|
||||
let time = Arg.(value & flag & info ["t"] ~doc:"Sort by time, newest first") in
|
||||
let reverse = Arg.(value & flag & info ["r"] ~doc:"reverse order") in
|
||||
let field = Arg.(value & opt (some string) None & info ["f"; "field"] ~docv:"FIELD" ~doc:"what to list") in
|
||||
let authors = Arg.(value & opt (some string) None & info ["a"; "authors"] ~docv:"AUTHORS" ~doc:"texts with authors") in
|
||||
let keywords= Arg.(value & opt (some string) None & info ["k"; "keywords"] ~docv:"KEYWORDS" ~doc:"texts with keywords") in
|
||||
let topics = Arg.(value & opt (some string) None & info ["topics"] ~docv:"TOPICS" ~doc:"texts with topics") in
|
||||
Term.(const text_list $ time $ reverse $ field $ authors $ keywords $ topics),
|
||||
Term.info "list" ~doc:"list texts" ~man:[ `S "DESCRIPTION"; `P "List texts" ]
|
||||
|
||||
let print_last =
|
||||
match A.of_path (Sys.getcwd ()) with
|
||||
| Error msg -> prerr_endline msg
|
||||
| Ok archive ->
|
||||
let last a (_t,fname) = match a with "" -> fname | x -> x in
|
||||
print_endline @@ A.fold ~order:A.oldest last "" archive
|
||||
|
||||
let last_term =
|
||||
Term.(const print_last),
|
||||
Term.info "last" ~doc:"most recent test" ~man:[ `S "DESCRIPTION"; `P "Print the filename of most recent text" ]
|
||||
|
||||
let split_filetypes files =
|
||||
let acc (dirs, files) x = if Sys.is_directory x then (x::dirs, files) else (dirs, x::files) in
|
||||
List.fold_left acc ([],[]) files
|
||||
|
||||
let file files = match A.of_path "." with
|
||||
| Error msg -> prerr_endline msg
|
||||
| Ok _archive ->
|
||||
let dirs, files = split_filetypes files in
|
||||
let link dir file = Unix.link file (dir ^"/"^ file) in
|
||||
List.iter (fun d -> List.iter (link d) files) dirs
|
||||
| Error msg -> prerr_endline msg
|
||||
| Ok _archive ->
|
||||
let dirs, files = split_filetypes files in
|
||||
let link dir file = Unix.link file (dir ^"/"^ file) in
|
||||
List.iter (fun d -> List.iter (link d) files) dirs
|
||||
|
||||
let file_term =
|
||||
let files = Arg.(value & pos_all string [] & info [] ~doc:"filenames") in
|
||||
@ -105,7 +121,7 @@ let default_cmd =
|
||||
let man = [ `S "BUGS"; `P "Submit bugs <mailto:logarion@lists.orbitalfox.eu?subject=Issue: " ] in
|
||||
Term.(ret (const (`Help (`Pager, None)))), Term.info "txt" ~version ~doc ~man
|
||||
|
||||
let cmds = [ init_term; new_term; file_term; unfile_term; list_term; Convert.term ]
|
||||
let cmds = [ init_term; new_term; file_term; unfile_term; list_term; last_term; Convert.term ]
|
||||
|
||||
let () =
|
||||
Random.self_init();
|
||||
|
@ -39,12 +39,12 @@ let list_iter fn {store;_} paths =
|
||||
|
||||
let iter_valid_text dir pred fn p =
|
||||
if text_filetype dir p then
|
||||
match to_text dir p with Error x -> prerr_endline x | Ok t -> if pred t then fn (t, dir^p)
|
||||
match to_text dir p with Error x -> prerr_endline x | Ok t -> if pred t then fn (t, p)
|
||||
|
||||
let fold_valid_text dir pred fn acc p =
|
||||
if not (text_filetype dir p) then acc else
|
||||
match to_text dir p with
|
||||
Error x -> prerr_endline x; acc | Ok t -> if pred t then fn acc (t, dir//p) else acc
|
||||
Error _x -> acc | Ok t -> if pred t then fn acc (t, p) else acc
|
||||
|
||||
let iter ?(predicate=fun _ -> true) ?order fn {store;_} =
|
||||
match order with
|
||||
@ -154,6 +154,6 @@ let of_path store =
|
||||
archivists = Person.Set.empty;
|
||||
id = Id.nil;
|
||||
kv = Store.KV.empty;
|
||||
store = Bos.OS.Env.opt_var "LOGARION_DIR" ~absent:"."
|
||||
store = Bos.OS.Env.opt_var "LOGARION_DIR" ~absent:(Sys.getcwd ())
|
||||
}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user