/++
read configuration files
- read config files
ao_config_files.d
+/
template SiSUconfigIn() {
private import
std.exception,
std.stdio,
std.utf,
std.conv : to;
private
struct ConfigIn {
private import std.file;
final private string readInConfigFile(string conf_sdl) {
string[] possible_config_path_locations = [
environment["PWD"] ~ "/.sisu",
environment["PWD"] ~ "/_sisu",
environment["HOME"] ~ "/.sisu",
"/etc/sisu"
];
string config_file_str;
foreach(pth; possible_config_path_locations) {
auto conf_file = format(
"%s/%s",
pth,
conf_sdl,
);
try {
if (exists(conf_file)) {
debug(configfile) {
writeln(conf_file);
}
config_file_str = readText(conf_file);
break;
}
}
catch (ErrnoException ex) {
}
catch (FileException ex) {
}
}
return config_file_str;
}
}
}
/+
+/
template SiSUconfigSDLang() {
struct ConfigSDLangRootTag {
private auto configSDLangRootTag(string configuration, string conf_sdl_filename) {
Tag sdl_root_conf;
try {
sdl_root_conf = parseSource(configuration);
}
catch(ParseException e) {
stderr.writeln("SDLang problem with content for ", conf_sdl_filename);
stderr.writeln(e.msg);
}
debug(sdlang) {
Value output_dir_structure_by = sdl_root_conf.tags["output_dir_structure_by"][0].values[0];
assert(output_dir_structure_by.type == typeid(string));
writeln(output_dir_structure_by);
writeln("conf SDL:");
writeln(sdl_root_conf.toSDLDocument());
}
return sdl_root_conf;
}
}
}
/+
+/
template SiSUconfigSDLangHub() {
mixin SiSUconfigIn;
mixin SiSUconfigSDLang;
struct ConfigHub {
final private auto configSDLang(string conf_sdl) {
auto conf_get = ConfigIn();
auto configuration = conf_get.readInConfigFile(conf_sdl);
auto conf = ConfigSDLangRootTag();
auto sdl_root = conf.configSDLangRootTag(configuration, conf_sdl);
return sdl_root;
}
}
}