aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/io_in
diff options
context:
space:
mode:
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;