aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/io_in
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2019-11-21 10:31:38 -0500
committerRalph Amissah <ralph.amissah@gmail.com>2019-11-22 09:54:26 -0500
commitf2f033305c7c031017cf8b8a6b7edf18e3a0ce67 (patch)
treefb3eb31c53624f677116d9ef62acf235f33d3467 /src/doc_reform/io_in
parentsegmented html harvest links cli option (diff)
yaml config, provide default if not readdoc-reform_v0.9.1
Diffstat (limited to 'src/doc_reform/io_in')
-rw-r--r--src/doc_reform/io_in/read_config_files.d58
1 files changed, 48 insertions, 10 deletions
diff --git a/src/doc_reform/io_in/read_config_files.d b/src/doc_reform/io_in/read_config_files.d
index c0893de..cb673e0 100644
--- a/src/doc_reform/io_in/read_config_files.d
+++ b/src/doc_reform/io_in/read_config_files.d
@@ -14,24 +14,45 @@ static template readConfigSite() {
std.file,
std.path;
mixin spineRgxInit;
- final auto readConfigSite(M,E)(
- M _manifested,
- E _env,
- string _cli_config_path_set = ""
- ) {
+ final auto readConfigSite(C)(C _conf_file_details) {
static auto rgx = Rgx();
- string config_file_str;
string conf_filename = "NONE";
- auto _conf_file_details = ConfigFilePaths!()(_manifested, _env, _cli_config_path_set);
- string[] possible_config_path_locations = _conf_file_details.possible_config_path_locations.config_local_site;
+ string config_file_str;
+ string default_config_file_str = format(q"┃
+flag:
+ act0: --html
+ act1: --html --epub
+#output:
+# path: ""
+default:
+ language: "en"
+ papersize: "a4"
+ text_wrap: "80"
+ digest: "sha256"
+search:
+ title: ""
+ flag: ""
+ action: ""
+ db: ""
+webserv:
+ url_domain: "not-configured"
+ url_root: "doc"
+ doc_path: "doc"
+ images: ""
+ cgi: ""
+ cgi_host: ""
+ cgi_host_path: ""
+ cgi_port: ""
+ cgi_user: ""
+┃");
foreach(conf_fn; [_conf_file_details.config_filename_site]) {
- foreach(pth; possible_config_path_locations) {
+ foreach(pth; _conf_file_details.possible_config_path_locations.config_local_site) {
char[] conf_file;
conf_filename = conf_fn;
if (exists(pth)) {
auto f_attrib = pth.getLinkAttributes;
if (
- possible_config_path_locations.length == 1
+ _conf_file_details.possible_config_path_locations.config_local_site.length == 1
&& f_attrib.attrIsFile
) {
conf_file = pth.to!(char[]);
@@ -54,6 +75,23 @@ static template readConfigSite() {
}
if (config_file_str.length > 0) { break; }
}
+ if (config_file_str.length > 0) {
+ import dyaml;
+ Node yaml_root;
+ try {
+ yaml_root = Loader.fromString(config_file_str).load();
+ } catch {
+ import std.stdio;
+ writeln("ERROR failed to read config file content, not parsed as yaml, program default used");
+ conf_filename = "VIRTUAL";
+ config_file_str = default_config_file_str;
+ }
+ }
+ if (config_file_str.length == 0) { /+ create dummy default config file +/
+ writeln("WARNING config file NOT found, default provided");
+ conf_filename = "VIRTUAL";
+ config_file_str = default_config_file_str;
+ }
struct _ConfContent {
string filename() {
return conf_filename;