From d61236952f19c1a1107a11cf11874104c0fe1a9b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 14 Nov 2019 11:16:09 -0500 Subject: 0.8.3 (if exists) get site config & output path - read once & read early: - once per batch processing - early (needed by metadata --harvest) --- src/doc_reform/source/read_config_files.d | 51 ++++++++++++++++++------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'src/doc_reform/source/read_config_files.d') diff --git a/src/doc_reform/source/read_config_files.d b/src/doc_reform/source/read_config_files.d index 4827fff..2b3e4fb 100644 --- a/src/doc_reform/source/read_config_files.d +++ b/src/doc_reform/source/read_config_files.d @@ -14,30 +14,42 @@ static template readConfigSite() { std.file, std.path; mixin DocReformRgxInit; - final auto readConfigSite(M,E)(M _manifested, E _env) { + final auto readConfigSite(M,E)( + M _manifested, + E _env, + string _cli_config_path_set = "" + ) { static auto rgx = Rgx(); string config_file_str; string conf_filename = "NONE"; - auto _conf_file_details = ConfigFilePaths!()(_manifested, _env); + 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; foreach(conf_fn; [_conf_file_details.config_filename_site]) { foreach(pth; possible_config_path_locations) { - char[] conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array; + char[] conf_file; conf_filename = conf_fn; - if (config_file_str.length > 0) { - // conf_filename = conf_fn; - break; - } - try { - if (exists(conf_file)) { - debug(io) { - writeln("WARNING (io debug) in config file found: ", conf_file); + if (exists(pth)) { + auto f_attrib = pth.getLinkAttributes; + if ( + possible_config_path_locations.length == 1 + && f_attrib.attrIsFile + ) { + conf_file = pth.to!(char[]); + conf_filename = pth.baseName; + } else if (f_attrib.attrIsDir) { + conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array; + conf_filename = conf_fn; + } + try { + if (exists(conf_file)) { + if (conf_file.getLinkAttributes.attrIsFile) { + config_file_str = conf_file.readText; + break; + } } - config_file_str = conf_file.readText; - break; + } catch (ErrnoException ex) { + } catch (FileException ex) { } - } catch (ErrnoException ex) { - } catch (FileException ex) { } } if (config_file_str.length > 0) { break; } @@ -80,16 +92,14 @@ static template readConfigDoc() { auto conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array; conf_filename = conf_fn; if (config_file_str.length > 0) { - // conf_filename = conf_fn; break; } try { if (exists(conf_file)) { - debug(io) { - writeln("WARNING (io debug) in config file found: ", conf_file); + if (conf_file.getLinkAttributes.attrIsFile) { + config_file_str = conf_file.readText; + break; } - config_file_str = conf_file.readText; - break; } } catch (ErrnoException ex) { } catch (FileException ex) { @@ -121,7 +131,6 @@ static template configReadSiteYAML() { doc_reform.source.paths_source, std.file, std.path; - import dyaml; final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) { string _configuration = configReadInSiteYAML!()(_manifested, _env); auto _conf_file_details = ConfigFilePaths!()(_manifested, _env); -- cgit v1.2.3