txt publish <id>; file and convert to standard dirs
git-svn-id: file:///srv/svn/repo/kosuzu/trunk@6 eb64cd80-c68d-6f47-b6a3-0ada418499da
This commit is contained in:
30
cli/publish.ml
Normal file
30
cli/publish.ml
Normal file
@@ -0,0 +1,30 @@
|
||||
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";
|
||||
"gmi", home ^ "/public/gemini";
|
||||
"", home ^ "/public/gopher";
|
||||
]
|
||||
|
||||
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.convert_dir (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 standart public dirs public_{html,gemini,gopher} if they exists" in
|
||||
Term.(const publish $ ids), Term.info "publish" ~doc ~man:[ `S "DESCRIPTION"; `P doc ]
|
||||
Reference in New Issue
Block a user