Last change
on this file since 14 was 13, checked in by fox, 3 years ago |
Accept files & directories for conversion
|
File size:
1.0 KB
|
Line | |
---|
1 | let 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/txt";
|
---|
10 | "gmi", home ^ "/public_gemini/txt";
|
---|
11 | "", home ^ "/public_gopher/txt";
|
---|
12 | ]
|
---|
13 |
|
---|
14 | open Logarion
|
---|
15 | let 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.at_path (fst t) false (snd t))
|
---|
24 | targets
|
---|
25 |
|
---|
26 | open Cmdliner
|
---|
27 | let 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.