cellar config set is now effective

This commit is contained in:
Nicholas O'Connor 2017-03-24 20:12:57 -07:00
parent f4de6406bb
commit f20b0899a1
4 changed files with 28 additions and 6 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
*.o *.o
*.so *.so
*/.deps */.deps
*.swp
build/ build/

View File

@ -31,14 +31,34 @@ void cellar::bottles::config_command(int argc, vector<string> argv) {
Bottle active_bottle = Bottle(homedir + "/.wine"); Bottle active_bottle = Bottle(homedir + "/.wine");
active_bottle.load_config(); active_bottle.load_config();
string value = active_bottle.get_config(argv[2]); string key = argv[2];
string value = active_bottle.get_config(key);
if (value != "") { if (value != "") {
output::statement(argv[2] + ": " + value); output::statement(key + ": " + value);
} else { } else {
output::error(argv[2] + " is not defined"); output::error(key + " is not defined");
} }
} else if (command == "set") { } else if (command == "set") {
if (argc < 4) {
output::statement("usage: " + argv[0] + " set <key> <value>"); output::statement("usage: " + argv[0] + " set <key> <value>");
return;
}
// TEMP
string homedir = getenv("HOME");
Bottle active_bottle = Bottle(homedir + "/.wine");
active_bottle.load_config();
string key = argv[2];
string newvalue = argv[3];
string oldvalue = active_bottle.get_config(key);
if (active_bottle.set_config(key, newvalue)) {
output::statement(key + ": " + newvalue + " (was " + oldvalue + ")");
} else {
output::error(key + ": " + oldvalue);
}
} else { } else {
output::statement("usage is one of:"); output::statement("usage is one of:");
output::statement("\t" + argv[0] + " get <key>"); output::statement("\t" + argv[0] + " get <key>");

View File

@ -58,5 +58,6 @@ string Bottle::get_config(string key) {
bool Bottle::set_config(string key, string value) { bool Bottle::set_config(string key, string value) {
this->config[key] = value; this->config[key] = value;
this->save_config();
return true; return true;
} }

View File

@ -49,7 +49,7 @@ void cellar::output::warning(string str_message, bool verbose) {
cerr << str_message << endl; cerr << str_message << endl;
} }
void cellar::output::warning(string str_message) { statement(str_message, false); } void cellar::output::warning(string str_message) { warning(str_message, false); }
void cellar::output::error(string str_message, bool verbose) { void cellar::output::error(string str_message, bool verbose) {
if (verbose and !cellar::verbose) { return; } if (verbose and !cellar::verbose) { return; }
@ -64,5 +64,5 @@ void cellar::output::error(string str_message, bool verbose) {
cerr << str_message << endl; cerr << str_message << endl;
} }
void cellar::output::error(string str_message) { statement(str_message, false); } void cellar::output::error(string str_message) { error(str_message, false); }