Slight rework so that config can have a base dir but the program can start in another one.

This commit is contained in:
Zed A. Shaw 2025-04-23 12:08:36 -04:00
parent d1c2352237
commit 3d4ddde96e
8 changed files with 32 additions and 13 deletions

View file

@ -5,8 +5,10 @@
using nlohmann::json;
using fmt::format;
std::filesystem::path Config::BASE_DIR{"."};
Config::Config(const std::string src_path) : $src_path(src_path) {
std::ifstream infile($src_path);
std::ifstream infile(Config::path_to($src_path));
$config = json::parse(infile);
}
@ -33,3 +35,11 @@ std::vector<std::string> Config::keys() {
return the_fucking_keys;
}
void Config::set_base_dir(const char *optarg) {
Config::BASE_DIR.assign(optarg);
}
std::filesystem::path Config::path_to(const std::string& path) {
return Config::BASE_DIR / path;
}