From e2400b290837a7bc99ece51ce62beb0ebc5f5ab8 Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Wed, 5 Jul 2017 14:35:41 -0700 Subject: [PATCH] Bottle::load_config now checks ~/.local/share/cellar.json and compiled defaults --- src/config/save_load.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/config/save_load.cpp b/src/config/save_load.cpp index 82db909..253ed95 100644 --- a/src/config/save_load.cpp +++ b/src/config/save_load.cpp @@ -19,6 +19,7 @@ namespace fs = boost::filesystem; using json = nlohmann::json; json cellar::global_config; +json cellar::compiled_config; bool Bottle::load_config() { bool globalconfig = false; @@ -48,6 +49,9 @@ bool Bottle::load_config() { sstr_globalpath << xdgdir << "/cellar"; } sstr_globalpath << "/cellar.json"; + + // see src/config/defaults.cpp.cog + compiled_config = cellar::config::get_default_config(); string globaljsonpath = sstr_globalpath.str(); if (fs::exists(globaljsonpath)) { @@ -89,6 +93,10 @@ bool Bottle::save_config() { string Bottle::get_config(string key) { if (this->config.find(key) != this->config.end()) { return this->config[key]; + } else if (cellar::global_config.find(key) != cellar::global_config.end()) { + return cellar::global_config[key]; + } else if (cellar::compiled_config.find(key) != cellar::compiled_config.end()) { + return cellar::compiled_config[key]; } else { return ""; }