Directory parameter for listing, defaults to txtdir
This commit is contained in:
parent
4ea44dd16c
commit
cc7515bfac
|
@ -2,7 +2,8 @@ open Logarion
|
||||||
module FS = File_store
|
module FS = File_store
|
||||||
module A = Archive
|
module A = Archive
|
||||||
|
|
||||||
let listing r order_opt reverse_opt number_opt paths_opt authors_opt topics_opt =
|
let listing r order_opt reverse_opt number_opt paths_opt authors_opt topics_opt dir =
|
||||||
|
let dir = if dir = "" then FS.txtdir () else dir in
|
||||||
let predicates = A.predicate A.authored authors_opt @ A.predicate A.topics topics_opt in
|
let predicates = A.predicate A.authored authors_opt @ A.predicate A.topics topics_opt in
|
||||||
let predicate text = List.fold_left (fun a e -> a && e text) true predicates in
|
let predicate text = List.fold_left (fun a e -> a && e text) true predicates in
|
||||||
let list_text (t, fnames) = Printf.printf "%s %s %s 𐄁 %s%s\n"
|
let list_text (t, fnames) = Printf.printf "%s %s %s 𐄁 %s%s\n"
|
||||||
|
@ -11,12 +12,12 @@ let listing r order_opt reverse_opt number_opt paths_opt authors_opt topics_opt
|
||||||
t.Text.title (if paths_opt then (List.fold_left (Printf.sprintf "%s\n@ %s") "" fnames) else "")
|
t.Text.title (if paths_opt then (List.fold_left (Printf.sprintf "%s\n@ %s") "" fnames) else "")
|
||||||
in
|
in
|
||||||
match order_opt with
|
match order_opt with
|
||||||
| false -> FS.iter ~r ~predicate list_text
|
| false -> FS.iter ~r ~dir ~predicate list_text
|
||||||
| true ->
|
| true ->
|
||||||
let order = match reverse_opt with true -> FS.newest | false -> FS.oldest in
|
let order = match reverse_opt with true -> FS.newest | false -> FS.oldest in
|
||||||
match number_opt with
|
match number_opt with
|
||||||
| Some number -> FS.iter ~r ~predicate ~order ~number list_text
|
| Some number -> FS.iter ~r ~dir ~predicate ~order ~number list_text
|
||||||
| None -> FS.iter ~r ~predicate ~order list_text
|
| None -> FS.iter ~r ~dir ~predicate ~order list_text
|
||||||
|
|
||||||
open Cmdliner
|
open Cmdliner
|
||||||
let term =
|
let term =
|
||||||
|
@ -30,7 +31,10 @@ let term =
|
||||||
~docv:"comma-separated names" ~doc:"texts by authors") in
|
~docv:"comma-separated names" ~doc:"texts by authors") in
|
||||||
let topics = Arg.(value & opt (some string) None & info ["topics"]
|
let topics = Arg.(value & opt (some string) None & info ["topics"]
|
||||||
~docv:"comma-separated topics" ~doc:"texts with topics") in
|
~docv:"comma-separated topics" ~doc:"texts with topics") in
|
||||||
Term.(const listing $ recurse $ time $ reverse $ number $ paths $ authed $ topics),
|
let dir = Arg.(value & pos 0 string "" & info []
|
||||||
|
~docv:"directory to index") in
|
||||||
|
Term.(const listing $ recurse $ time $ reverse $ number $ paths $ authed $ topics $ dir),
|
||||||
Term.info "list" ~doc:"list texts" ~man:[ `S "DESCRIPTION";
|
Term.info "list" ~doc:"list texts" ~man:[ `S "DESCRIPTION";
|
||||||
`P "List header information for current directory. If -R is used, list header
|
`P "Diplays text id, date, author, title for a directory.
|
||||||
information for texts found in subdirectories too, along with their filepaths" ]
|
If directory argument is ommitted, $txtdir is used, where empty value defaults to ~/.local/share/texts.
|
||||||
|
If -R is used, list header information for texts found in subdirectories too." ]
|
||||||
|
|
|
@ -13,7 +13,9 @@ let term =
|
||||||
~docv:"comma-separated names" ~doc:"texts by authors") in
|
~docv:"comma-separated names" ~doc:"texts by authors") in
|
||||||
let topics = Arg.(value & opt (some string) None & info ["topics"]
|
let topics = Arg.(value & opt (some string) None & info ["topics"]
|
||||||
~docv:"comma-separated topics" ~doc:"texts with topics") in
|
~docv:"comma-separated topics" ~doc:"texts with topics") in
|
||||||
Term.(const Listing.listing $ recurse $ (const true) $ reverse $ number $ paths $ authed $ topics),
|
let dir = Arg.(value & pos 0 string "" & info []
|
||||||
|
~docv:"directory to index") in
|
||||||
|
Term.(const Listing.listing $ recurse $ (const true) $ reverse $ number $ paths $ authed $ topics $ dir),
|
||||||
Term.info "recent" ~doc:"list recent texts" ~man:[ `S "DESCRIPTION";
|
Term.info "recent" ~doc:"list recent texts" ~man:[ `S "DESCRIPTION";
|
||||||
`P "List header information of most recent texts. If -R is used, list header
|
`P "List header information of most recent texts. If -R is used, list header
|
||||||
information for texts found in subdirectories too, along with their filepaths" ]
|
information for texts found in subdirectories too, along with their filepaths" ]
|
||||||
|
|
Loading…
Reference in New Issue