#include "CConfiguration.hpp"
#include "nlohmann/json.hpp"

#include <fstream>


namespace CosmicCore {
    CModuleConfig CConfiguration::moduleConfiguration;


    void CModuleConfig::parse(nlohmann::json& jsonModule)
    {
        modulesDirectory = jsonModule["modulesDirectory"].get<std::filesystem::path>();
    }

    void CConfiguration::init(std::filesystem::path configFilePath)
    {
        std::ifstream fileConf(configFilePath);
        auto json = nlohmann::json::parse(fileConf);
        if(json.contains("Modules"))
        {
           moduleConfiguration.parse(json["Modules"]);
        }
    }
}