Fixed import

This commit is contained in:
Maxwell Ruben
2026-03-18 23:12:44 -05:00
parent 099e3d5e92
commit 7400f13c68

View File

@ -1,41 +1,41 @@
module thirdworld.common.config;
import common.log;
import std.file : readText, exists, isFile, write;
import std.json;
import std.path : absolutePath;
JSONValue structToJSON(T)(T s) {
JSONValue json;
foreach (member; __traits(allMembers, T)) {
json[member] = JSONValue(__traits(getMember, s, member));
}
return json;
}
void createConfigFile(T)(string path) {
path = absolutePath(path);
if (exists(path) && isFile(path)) {
return;
}
logInfo("No config file found, creating default config file at '%s'", path);
T config;
auto json = structToJSON(config);
write(path, json.toPrettyString());
}
T configFromFile(T)(string path) {
string text = readText(path);
JSONValue json = parseJSON(text);
T config;
foreach (member; __traits(allMembers, T)) {
config[member] = json[member];
}
return config;
module thirdworld.common.config;
import thirdworld.common.log;
import std.file : readText, exists, isFile, write;
import std.json;
import std.path : absolutePath;
JSONValue structToJSON(T)(T s) {
JSONValue json;
foreach (member; __traits(allMembers, T)) {
json[member] = JSONValue(__traits(getMember, s, member));
}
return json;
}
void createConfigFile(T)(string path) {
path = absolutePath(path);
if (exists(path) && isFile(path)) {
return;
}
logInfo("No config file found, creating default config file at '%s'", path);
T config;
auto json = structToJSON(config);
write(path, json.toPrettyString());
}
T configFromFile(T)(string path) {
string text = readText(path);
JSONValue json = parseJSON(text);
T config;
foreach (member; __traits(allMembers, T)) {
config[member] = json[member];
}
return config;
}