source: code/trunk/cli/publish.ml@ 11

Last change on this file since 11 was 10, checked in by novaburst, 3 years ago

Fix some typos on the docs

Signed-off-by: Aoi Koizumi (古泉 あおい) <novaburst@…>

File size: 1019 bytes
Line 
1let targets () =
2 let home =
3 try Sys.getenv "txtpubdir" with Not_found ->
4 try Sys.getenv "HOME" with Not_found -> ""
5 in
6 List.filter
7 (fun x -> try Sys.is_directory (snd x) with Sys_error _ -> false)
8 [
9 "htm", home ^ "/public/html";
10 "gmi", home ^ "/public/gemini";
11 "", home ^ "/public/gopher";
12 ]
13
14open Logarion
15let publish ids =
16 let predicate t = List.mem t.Text.id ids in
17 let targets = targets () in
18 let pub_dirs = List.map (fun x -> snd x) targets in
19 try File_store.iter ~predicate (fun (_t, p) -> File.file ((List.hd p)::pub_dirs))
20 with Unix.Unix_error (Unix.EEXIST, _, _) -> ();
21 List.iter (fun t ->
22 Index.((load (snd t)) false None None None None);
23 Convert.convert_dir (fst t) false (snd t))
24 targets
25
26open Cmdliner
27let term =
28 let ids = Arg.(value & pos_all string [] & info [] ~docv:"text ids") in
29 let doc = "convert texts into standard public dirs public_{html,gemini,gopher} if they exist" in
30 Term.(const publish $ ids), Term.info "publish" ~doc ~man:[ `S "DESCRIPTION"; `P doc ]
Note: See TracBrowser for help on using the repository browser.