config command can get values now
This commit is contained in:
parent
22cffca2d8
commit
c877663932
@ -1,3 +1,4 @@
|
|||||||
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -18,5 +19,30 @@ void cellar::bottles::config_command(int argc, vector<string> argv) {
|
|||||||
}
|
}
|
||||||
string command = argv[1];
|
string command = argv[1];
|
||||||
|
|
||||||
output::statement(command);
|
// BULLSHIT: switch can't be used for strings, according to gcc
|
||||||
|
if (command == "get") {
|
||||||
|
if (argc < 3) {
|
||||||
|
output::error("usage: " + argv[0] + " get <key>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TEMP
|
||||||
|
string homedir = getenv("HOME");
|
||||||
|
Bottle active_bottle = Bottle(homedir + "/.wine");
|
||||||
|
active_bottle.load_config();
|
||||||
|
|
||||||
|
string value = active_bottle.get_config(argv[2]);
|
||||||
|
if (value != "") {
|
||||||
|
output::statement(argv[2] + ": " + value);
|
||||||
|
} else {
|
||||||
|
output::error(argv[2] + " is not defined");
|
||||||
|
}
|
||||||
|
} else if (command == "set") {
|
||||||
|
output::statement("usage: " + argv[0] + " set <key> <value>");
|
||||||
|
} else {
|
||||||
|
output::statement("usage is one of:");
|
||||||
|
output::statement("\t" + argv[0] + " get <key>");
|
||||||
|
output::statement("\t" + argv[0] + " set <key> <value>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,3 +47,16 @@ bool Bottle::save_config() {
|
|||||||
configstream << this->config.dump(4);
|
configstream << this->config.dump(4);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string Bottle::get_config(string key) {
|
||||||
|
if (this->config.find(key) != this->config.end()) {
|
||||||
|
return this->config[key];
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bottle::set_config(string key, string value) {
|
||||||
|
this->config[key] = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user