diff --git a/src/cellar.cpp.cog b/src/cellar.cpp.cog index 9116fd1..97ba7ce 100644 --- a/src/cellar.cpp.cog +++ b/src/cellar.cpp.cog @@ -68,7 +68,7 @@ int main(int argc, char* argv[]) { cmdparse.parse(argc, argv); dryrun = dryrunarg.getValue(); - verbose = verbosearg.getValue(); + verbose = dryrun || verbosearg.getValue(); // BULLSHIT: trying to use str.format on this string causes bizarre compiler errors /*[[[cog diff --git a/src/config/cli_handler.cpp b/src/config/cli_handler.cpp index 9a23052..2168078 100644 --- a/src/config/cli_handler.cpp +++ b/src/config/cli_handler.cpp @@ -1,10 +1,13 @@ #include #include +#include "tclap/CmdLine.h" + #include "bottles.hpp" #include "cellar.hpp" #include "internal/config.hpp" #include "output.hpp" +#include "version.hpp" using namespace std; using namespace cellar; @@ -13,11 +16,28 @@ using namespace cellar::bottles; using json = nlohmann::json; void cellar::config::config_command(int argc, vector argv) { - if (argc == 1) { - output::error("not enough arguments"); - return; - } - string command = argv[1]; + const string desc = "Change cellar configuration options"; + const string versionstr = version::short_version(); + TCLAP::CmdLine cmdparse(desc, ' ', versionstr, false); + + TCLAP::SwitchArg globalarg("g", "global", "Use global user configuration (~/.local/share/cellar/cellar.json)"); + cmdparse.add(globalarg); + + TCLAP::UnlabeledValueArg commandarg("command", "", true, "get", "command"); + cmdparse.add(commandarg); + + TCLAP::UnlabeledValueArg keyarg("key", "", true, "", "key"); + cmdparse.add(keyarg); + + TCLAP::UnlabeledValueArg valarg("value", "", false, "", "value"); + cmdparse.add(valarg); + + cmdparse.parse(argv); + + bool global = globalarg.getValue(); + string command = commandarg.getValue(); + string key = keyarg.getValue(); + string value = valarg.getValue(); // BULLSHIT: switch can't be used for strings, according to gcc if (command == "get") { @@ -26,9 +46,6 @@ void cellar::config::config_command(int argc, vector argv) { return; } - string key = argv[2]; - string value = active_bottle.get_config(key); - if (value != "") { output::statement(key + ": " + value); } else {