aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/io_in
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2020-04-04 17:25:56 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2020-05-20 11:27:25 -0400
commitdb96528baa55151826442f61ddfea2cd006ef68d (patch)
tree1325fd983b466d8157248648b6ef8a33beee5a93 /src/doc_reform/io_in
parentsql, sqlite internal site links (diff)
config, where used without document processing
Diffstat (limited to 'src/doc_reform/io_in')
-rw-r--r--src/doc_reform/io_in/paths_source.d41
-rw-r--r--src/doc_reform/io_in/read_config_files.d13
2 files changed, 28 insertions, 26 deletions
diff --git a/src/doc_reform/io_in/paths_source.d b/src/doc_reform/io_in/paths_source.d
index 0cf0478..432b484 100644
--- a/src/doc_reform/io_in/paths_source.d
+++ b/src/doc_reform/io_in/paths_source.d
@@ -18,7 +18,7 @@ template PodManifest() {
mixin spineRgxIn;
static auto rgx = RgxI();
@safe auto PodManifest(O)(
- O _opt_actions,
+ O _opt_action,
string _pth=""
) {
struct ManifestFile_ {
@@ -40,10 +40,10 @@ template PodManifest() {
_manifest_path = m.captures["podpath"];
}
} else {
- if (_opt_actions.verbose || _opt_actions.very_verbose || _opt_actions.debug_do) {
+ if (_opt_action.verbose || _opt_action.very_verbose || _opt_action.debug_do) {
writeln("WARNING, src is not a pod, issue with manifest_path: ", _pth); // remove? unless can distinguish pod
}
- _manifest_path = null; // _manifest_path = "";
+ _manifest_path = "";
}
return _manifest_path;
}
@@ -73,13 +73,13 @@ template PathMatters() {
static auto rgx = RgxI();
static auto mkup = InlineMarkup();
@safe auto PathMatters(O,E)(
- O _opt_actions,
+ O _opt_action,
E _env,
string _pth,
string _fns = "",
char[][] _manifest_fn_list = [[]],
) {
- @safe auto _manifested = PodManifest!()(_opt_actions, _pth);
+ @safe auto _manifested = PodManifest!()(_opt_action, _pth);
struct ManifestMatters_ {
auto env() {
auto _env = _env;
@@ -96,7 +96,7 @@ template PathMatters() {
@safe auto opt() {
struct Opt_ {
auto action() {
- return _opt_actions;
+ return _opt_action;
}
}
return Opt_();
@@ -155,7 +155,7 @@ template PathMatters() {
}
@safe auto src() {
string _fns = _fns; // required here by dmd & not by ldc (for D:2078)
- auto _opt_actions = _opt_actions;
+ auto _opt_action = _opt_action;
auto _env = _env;
struct SRC_ {
@safe bool is_pod() {
@@ -270,7 +270,7 @@ template PathMatters() {
assert(_dir == absolute_path_to_src
.match(rgx.src_base_parent_dir_name).captures["dir"]);
}
- if (_opt_actions.debug_do) {
+ if (_opt_action.debug_do) {
writeln("--> (base_dir) ", _dir);
}
return _dir;
@@ -302,7 +302,7 @@ template PathMatters() {
} else {
_dir = ((path_and_fn.chainPath("../../")).asNormalizedPath).array;
}
- if (_opt_actions.debug_do) {
+ if (_opt_action.debug_do) {
writeln("--> (base_dir_path) ", _dir);
}
return _dir;
@@ -348,7 +348,7 @@ template PathMatters() {
} else {
_dir = (absolute_path_to_src).match(rgx.src_base_parent_dir_name).captures["dir"];
}
- if (_opt_actions.debug_do) {
+ if (_opt_action.debug_do) {
writeln("--> (base_parent_dir) ", _dir);
}
return _dir;
@@ -384,10 +384,10 @@ template PathMatters() {
struct Out_ {
@safe auto path() {
auto _output_path = _env["pwd"];
- if ((_opt_actions.output_dir_set.length > 0)
- && isValidPath(_opt_actions.output_dir_set)
+ if ((_opt_action.output_dir_set.length > 0)
+ && isValidPath(_opt_action.output_dir_set)
) {
- _output_path = ((_opt_actions.output_dir_set).asNormalizedPath).array;
+ _output_path = ((_opt_action.output_dir_set).asNormalizedPath).array;
if (!exists(_output_path)) {
try {
_output_path.mkdirRecurse;
@@ -409,10 +409,10 @@ template PathMatters() {
return ManifestMatters_();
}
}
-template ConfigFilePaths() {
+template configFilePaths() {
mixin spineRgxIn;
static auto rgx = RgxI();
- @safe auto ConfigFilePaths(M,E)(
+ @safe auto configFilePaths(M,E)(
M _manifested,
E _env,
string _cli_config_path_set = ""
@@ -465,10 +465,9 @@ template ConfigFilePaths() {
_dr_doc_conf_pwd_d,
];
}
- } else {
- _possible_config_path_locations = [
- _cli_config_path_set
- ];
+ } else if (_cli_config_path_set.isDir) {
+ _possible_config_path_locations = [_cli_config_path_set ];
+ // } else if (_cli_config_path_set.isFile) { // use file, taken care of elsewhere
}
/+ FIX clean up conf paths ↑
(compare pwd to doc path location, and build config path)
@@ -490,10 +489,10 @@ template ConfigFilePaths() {
_possible_config_path_locations = [
_dot_pwd,
_underscore_pwd,
+ _collection_root_a,
+ _collection_root_b,
_dot_home,
"/etc/dr",
- _collection_root_a, // set priority higher?
- _collection_root_b // set priority higher?
];
} else {
/+ config document (& or local site) on filesystem +/
diff --git a/src/doc_reform/io_in/read_config_files.d b/src/doc_reform/io_in/read_config_files.d
index 69c2f55..9180c20 100644
--- a/src/doc_reform/io_in/read_config_files.d
+++ b/src/doc_reform/io_in/read_config_files.d
@@ -12,7 +12,7 @@ import
doc_reform.meta.rgx;
template readConfigSite() {
- @system final auto readConfigSite(C)(C _conf_file_details) {
+ @system final auto readConfigSite(C,O)(C _conf_file_details, O _opt_action) {
mixin spineRgxIn;
static auto rgx = RgxI();
string conf_filename = "NONE";
@@ -70,6 +70,9 @@ webserv:
try {
if (exists(conf_file)) {
if (conf_file.getLinkAttributes.attrIsFile) {
+ if (_opt_action.verbose || _opt_action.very_verbose || _opt_action.debug_do) {
+ writeln("config file used: \"", conf_file, "\" (cli flag settings override config file's individual settings)");
+ }
config_file_str = conf_file.readText;
break;
}
@@ -93,7 +96,7 @@ webserv:
config_file_str = default_config_file_str;
}
}
- if (config_file_str.length == 0) { /+ create dummy default config file +/
+ if (config_file_str.length == 0) { /+ use dummy default config file +/
writeln("WARNING config file NOT found, default provided");
conf_filename = "VIRTUAL";
config_file_str = default_config_file_str;
@@ -128,7 +131,7 @@ static template readConfigDoc() {
static auto rgx = RgxI();
string config_file_str;
string conf_filename = "NONE";
- auto _conf_file_details = ConfigFilePaths!()(_manifested, _env);
+ auto _conf_file_details = configFilePaths!()(_manifested, _env);
string[] possible_config_path_locations = _conf_file_details.possible_config_path_locations.dr_document_make;
foreach(conf_fn; [_conf_file_details.config_filename_document]) {
foreach(pth; possible_config_path_locations) {
@@ -176,7 +179,7 @@ static template configReadSiteYAML() {
doc_reform.io_in.paths_source;
@safe final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) {
string _configuration = configReadInSiteYAML!()(_manifested, _env);
- auto _conf_file_details = ConfigFilePaths!()(_manifested, _env);
+ auto _conf_file_details = configFilePaths!()(_manifested, _env);
string _conf_yaml_fn = _conf_file_details.config_filename_site;
YAMLDocument _yaml_conf = configYAML!()(_configuration, _conf_yaml_fn);
return _yaml_conf;
@@ -190,7 +193,7 @@ static template configReadDocYAML() {
doc_reform.io_in.paths_source;
@safe final YAMLDocument configReadDocYAML(M,E)(M _manifested, E _env) {
string _configuration = configReadInDocYAML!()(_manifested, _env);
- auto _conf_file_details = ConfigFilePaths!()(_manifested, _env);
+ auto _conf_file_details = configFilePaths!()(_manifested, _env);
string _conf_yaml_fn = _conf_file_details.config_filename_document;
YAMLDocument _yaml_conf = configYAML!()(_configuration, _conf_yaml_fn);
return _yaml_conf;