Bottle::load_config now checks ~/.local/share/cellar.json and compiled defaults
This commit is contained in:
parent
96ccab40f7
commit
e2400b2908
@ -19,6 +19,7 @@ namespace fs = boost::filesystem;
|
|||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
json cellar::global_config;
|
json cellar::global_config;
|
||||||
|
json cellar::compiled_config;
|
||||||
|
|
||||||
bool Bottle::load_config() {
|
bool Bottle::load_config() {
|
||||||
bool globalconfig = false;
|
bool globalconfig = false;
|
||||||
@ -48,6 +49,9 @@ bool Bottle::load_config() {
|
|||||||
sstr_globalpath << xdgdir << "/cellar";
|
sstr_globalpath << xdgdir << "/cellar";
|
||||||
}
|
}
|
||||||
sstr_globalpath << "/cellar.json";
|
sstr_globalpath << "/cellar.json";
|
||||||
|
|
||||||
|
// see src/config/defaults.cpp.cog
|
||||||
|
compiled_config = cellar::config::get_default_config();
|
||||||
|
|
||||||
string globaljsonpath = sstr_globalpath.str();
|
string globaljsonpath = sstr_globalpath.str();
|
||||||
if (fs::exists(globaljsonpath)) {
|
if (fs::exists(globaljsonpath)) {
|
||||||
@ -89,6 +93,10 @@ bool Bottle::save_config() {
|
|||||||
string Bottle::get_config(string key) {
|
string Bottle::get_config(string key) {
|
||||||
if (this->config.find(key) != this->config.end()) {
|
if (this->config.find(key) != this->config.end()) {
|
||||||
return this->config[key];
|
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 {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user