30 lines
1 KiB
OCaml
30 lines
1 KiB
OCaml
let targets () =
|
|
let home =
|
|
try Sys.getenv "txtpubdir" with Not_found ->
|
|
try Sys.getenv "HOME" with Not_found -> ""
|
|
in
|
|
List.filter
|
|
(fun x -> try Sys.is_directory (snd x) with Sys_error _ -> false)
|
|
[
|
|
"htm", home ^ "/public_html/txt";
|
|
"gmi", home ^ "/public_gemini/txt";
|
|
"", home ^ "/public_gopher/txt";
|
|
]
|
|
|
|
open Logarion
|
|
let publish ids =
|
|
let predicate t = List.mem t.Text.id ids in
|
|
let targets = targets () in
|
|
let pub_dirs = List.map (fun x -> snd x) targets in
|
|
try File_store.iter ~predicate (fun (_t, p) -> File.file ((List.hd p)::pub_dirs))
|
|
with Unix.Unix_error (Unix.EEXIST, _, _) -> ();
|
|
List.iter (fun t ->
|
|
Index.((load (snd t)) false None None None None);
|
|
Convert.at_path (fst t) false (snd t))
|
|
targets
|
|
|
|
open Cmdliner
|
|
let term =
|
|
let ids = Arg.(value & pos_all string [] & info [] ~docv:"text ids") in
|
|
let doc = "convert texts into standard public dirs public_{html,gemini,gopher} if they exist" in
|
|
Term.(const publish $ ids), Term.info "publish" ~doc ~man:[ `S "DESCRIPTION"; `P doc ]
|