subargv[0] is now the expected value of "cellar <command>"

This commit is contained in:
Nicholas O'Connor 2017-03-23 17:23:59 -07:00
parent e2382719d5
commit af056ee961
2 changed files with 9 additions and 2 deletions

View File

@ -8,5 +8,5 @@
using namespace std; using namespace std;
void cellar::bottles::switch_active_bottle(int argc, vector<string> argv) { void cellar::bottles::switch_active_bottle(int argc, vector<string> argv) {
cout << argc << endl; cout << argv[0] << endl;
} }

View File

@ -47,7 +47,14 @@ 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) {
vector<string> subargv = subargs.getValue(); vector<string> subargv;
stringstream sstr;
sstr << "cellar ";
sstr << usercmd;
subargv.push_back(sstr.str());
for (auto item : subargs.getValue()) {
subargv.push_back(item);
}
commands::command_map[usercmd](subargv.size(), subargv); commands::command_map[usercmd](subargv.size(), subargv);
} else { } else {
cerr << "invalid command: " << usercmd << endl; cerr << "invalid command: " << usercmd << endl;