mirror of
https://github.com/davidallendj/gdpm.git
synced 2025-12-20 03:27:02 -07:00
Fixed bugs and issues with linking tests
This commit is contained in:
parent
65be8090d3
commit
d4b1ea90c6
11 changed files with 27 additions and 21 deletions
|
|
@ -58,15 +58,17 @@ namespace gdpm::config{
|
|||
}
|
||||
|
||||
|
||||
context load(std::filesystem::path path, int verbose){
|
||||
gdpm::error load(std::filesystem::path path, context& config, int verbose){
|
||||
std::fstream file;
|
||||
gdpm::error error;
|
||||
file.open(path, std::ios::in);
|
||||
if(!file){
|
||||
if(verbose){
|
||||
log::info("No configuration file found. Creating a new one.");
|
||||
save(make_context(), verbose);
|
||||
config = make_context();
|
||||
save(config.path, config, verbose);
|
||||
}
|
||||
return config;
|
||||
return error;
|
||||
}
|
||||
else if(file.is_open()){
|
||||
/*
|
||||
|
|
@ -89,7 +91,7 @@ namespace gdpm::config{
|
|||
|
||||
if(!doc.IsObject()){
|
||||
log::error("Could not load config file.");
|
||||
return config;
|
||||
return error;
|
||||
}
|
||||
|
||||
assert(doc.IsObject());
|
||||
|
|
@ -139,11 +141,11 @@ namespace gdpm::config{
|
|||
config.enable_sync = _get_value_int(doc, "enable_sync");
|
||||
config.enable_file_logging = _get_value_int(doc, "enable_file_logging");
|
||||
}
|
||||
return config;
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
int save(std::filesystem::path path, const context& config, int verbose){
|
||||
gdpm::error save(std::filesystem::path path, const context& config, int verbose){
|
||||
using namespace rapidjson;
|
||||
|
||||
/* Build a JSON string to pass to document */
|
||||
|
|
@ -160,7 +162,7 @@ namespace gdpm::config{
|
|||
PrettyWriter<OStreamWrapper> writer(osw);
|
||||
doc.Accept(writer);
|
||||
|
||||
return 0;
|
||||
return gdpm::error();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ namespace gdpm::package_manager{
|
|||
|
||||
/* Check for config and create if not exists */
|
||||
if(!std::filesystem::exists(config.path)){
|
||||
config::save(config);
|
||||
config::save(config.path, config);
|
||||
}
|
||||
config = config::load(config.path);
|
||||
config::load(config.path, config);
|
||||
config.enable_sync = true;
|
||||
std::string json = to_json(config);
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ namespace gdpm::package_manager{
|
|||
|
||||
void finalize(){
|
||||
curl_easy_cleanup(curl);
|
||||
config::save(config);
|
||||
config::save(config.path, config);
|
||||
// curl_global_cleanup();
|
||||
}
|
||||
|
||||
|
|
@ -622,7 +622,7 @@ namespace gdpm::package_manager{
|
|||
/* Set option variables first to be used in functions below. */
|
||||
if(result.count("config")){
|
||||
config.path = result["config"].as<std::string>();
|
||||
config = config::load(config.path);
|
||||
config::load(config.path, config);
|
||||
log::info("Config: {}", config.path);
|
||||
}
|
||||
if(result.count("add-remote")){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue