diff --git a/src/bottles/config/cli_handler.cpp b/src/bottles/config/cli_handler.cpp index ded49cd..a0538b4 100644 --- a/src/bottles/config/cli_handler.cpp +++ b/src/bottles/config/cli_handler.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -18,5 +19,30 @@ void cellar::bottles::config_command(int argc, vector argv) { } 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 "); + 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 "); + } else { + output::statement("usage is one of:"); + output::statement("\t" + argv[0] + " get "); + output::statement("\t" + argv[0] + " set "); + return; + } } diff --git a/src/bottles/config/save_load.cpp b/src/bottles/config/save_load.cpp index 43366c4..7787968 100644 --- a/src/bottles/config/save_load.cpp +++ b/src/bottles/config/save_load.cpp @@ -47,3 +47,16 @@ bool Bottle::save_config() { configstream << this->config.dump(4); 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; +}