commands now actually receive subarguments

This commit is contained in:
Nicholas O'Connor 2017-03-23 15:25:56 -07:00
parent b4f5740006
commit 38d6419c23

View File

@ -32,9 +32,13 @@ int main(int argc, char* argv[]) {
const string desc = "bottle management tool for WINE connoisseurs"; const string desc = "bottle management tool for WINE connoisseurs";
const string versionstr = version::short_version(); const string versionstr = version::short_version();
TCLAP::CmdLine cmdparse(desc, ' ', versionstr, false); TCLAP::CmdLine cmdparse(desc, ' ', versionstr, false);
TCLAP::UnlabeledValueArg<string> command("command", "Specific command to run.", true, "help", "command"); TCLAP::UnlabeledValueArg<string> command("command", "Specific command to run.", true, "help", "command");
cmdparse.add(command); cmdparse.add(command);
TCLAP::UnlabeledMultiArg<string> subargs("subargs", "Sub-arguments", false, "", "subarg");
cmdparse.add(subargs);
cmdparse.parse(argc, argv); cmdparse.parse(argc, argv);
for (auto item : commands::bottles_commands()) { for (auto item : commands::bottles_commands()) {
@ -43,9 +47,8 @@ int main(int argc, char* argv[]) {
string usercmd = command.getValue(); string usercmd = command.getValue();
if (commands::command_map.count(usercmd) > 0) { if (commands::command_map.count(usercmd) > 0) {
int subargc = 0; vector<string> subargv = subargs.getValue();
vector<string> subargv; commands::command_map[usercmd](subargv.size(), subargv);
commands::command_map[usercmd](subargc, subargv);
} else { } else {
cerr << "invalid command: " << usercmd << endl; cerr << "invalid command: " << usercmd << endl;
return 1; return 1;