- Timestamp:
- Jul 30, 2022, 12:58:02 PM (3 years ago)
- Location:
- trunk/cli
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/convert.ml
r10 r13 26 26 t 27 27 28 let convert_allconverters noindex dir id kv =28 let directory converters noindex dir id kv = 29 29 let empty = Topic_set.Map.empty in 30 30 let repo = Conversion.{ id; dir; kv; topic_roots = []; topics = empty; texts = [] } in … … 39 39 Printf.printf "Converted: %d Indexed: %d\n" count (List.length texts) 40 40 41 let convert_dir types noindex dir=42 match dir with "" -> prerr_endline "unspecified dir"43 | dir ->41 let at_path types noindex path = 42 match path with "" -> prerr_endline "unspecified text file or directory" 43 | dir when Sys.file_exists dir && Sys.is_directory dir -> 44 44 let fname = Filename.concat dir "index.pck" in 45 match Header_pack.of_string @@ File_store.to_string fname with45 (match Header_pack.of_string @@ File_store.to_string fname with 46 46 | Error s -> prerr_endline s 47 47 | Ok { info; _ } -> … … 52 52 let kv = Store.KV.add "Locations" (String.concat ";\n" info.Header_pack.locations) kv in 53 53 let cs = converters types kv in 54 convert_all cs noindex dir info.Header_pack.id kv 54 directory cs noindex dir info.Header_pack.id kv) 55 | path when Sys.file_exists path -> 56 let repo = Conversion.{ 57 id = ""; dir = ""; kv = Store.KV.empty; topic_roots = []; 58 topics = Topic_set.Map.empty; texts = [] } in 59 let cs = converters types repo.kv in 60 (match File_store.to_text path with 61 | Ok text -> ignore @@ convert cs repo (text, [path]) 62 | Error s -> prerr_endline s) 63 | path -> Printf.eprintf "Path doesn't exist: %s" path 55 64 56 65 open Cmdliner 57 66 let term = 58 let directory = Arg.(value & pos 0 string "" & info [] ~docv:"target directory"59 ~doc:" Directory to convert") in60 let types = Arg.(value & opt string "all" & info ["t"; "type"] ~docv:" TYPES"61 ~doc:"Convert totype") in67 let path = Arg.(value & pos 0 string "" & info [] ~docv:"path" 68 ~doc:"Text file or directory to convert. Ff directory is provided, it must contain an index.pck (see: txt index)") in 69 let types = Arg.(value & opt string "all" & info ["t"; "type"] ~docv:"output type" 70 ~doc:"Convert to file type") in 62 71 let noindex = Arg.(value & flag & info ["noindex"] 63 ~doc:" don't create indices in target format") in64 Term.(const convert_dir $ types $ noindex $ directory),72 ~doc:"Don't create indices in target format") in 73 Term.(const at_path $ types $ noindex $ path), 65 74 Term.info "convert" ~doc:"convert texts" 66 ~man:[ `S "DESCRIPTION"; `P "Convert text s within a directory to another format.67 Directory must contain an index.pck. Run `txt index` first." ]75 ~man:[ `S "DESCRIPTION"; `P "Convert text or indexed texts within a directory to another format. 76 If path is a directory must contain an index.pck. Run `txt index` first." ] -
trunk/cli/publish.ml
r12 r13 21 21 List.iter (fun t -> 22 22 Index.((load (snd t)) false None None None None); 23 Convert. convert_dir(fst t) false (snd t))23 Convert.at_path (fst t) false (snd t)) 24 24 targets 25 25
Note:
See TracChangeset
for help on using the changeset viewer.