diff --git a/cli/publish.ml b/cli/publish.ml index 51106af..e959bdd 100644 --- a/cli/publish.ml +++ b/cli/publish.ml @@ -5,9 +5,26 @@ let targets pubdir = List.fold_left [] ["htm,atom", "public_html/"; "gmi,gmi-atom", "public_gemini/"; "", "public_gopher/"] +let wizard () = + print_endline "No txt.conf found. It's required for the repository name & id. Create one? (y/N)"; + match input_line stdin with + |"y"-> + let title = + print_endline "Title for repository: "; + input_line stdin in + let authors = + print_endline "Authors (format: name ): "; + input_line stdin in + Logarion.File_store.file "txt.conf" + (Printf.sprintf "Id: %s\nTitle: %s\nAuthors: %s\n" (Logarion.Id.generate ()) title authors); + Logarion.File_store.of_kv_file () + | _ -> print_endline "Create a txt.conf and run publish again"; exit 1 + open Logarion let publish pubdir ids = - let kv = Logarion.File_store.of_kv_file () in + let kv = + match Logarion.File_store.of_kv_file () + with x when x = Logarion.Store.KV.empty -> wizard () | x -> x in let predicate t = List.mem t.Text.id ids in let pubdir_source, pubdir = match pubdir with Some d -> "--pubdir ", d | None -> try "txt.conf:Pubdir", Logarion.Store.KV.find "Pubdir" kv with Not_found -> @@ -15,7 +32,8 @@ let publish pubdir ids = in let targets = targets pubdir in if targets = [] then - Printf.eprintf "No target directories in %s='%s'\n" pubdir_source pubdir + Printf.eprintf "No target directories in %s='%s' (for example %s)\n" + pubdir_source pubdir (Filename.concat pubdir "public_html") else begin let pub_dirs = List.map (fun x -> snd x) targets in File_store.iter ~predicate (fun (_t, p) ->