X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=commandoptionparser.cpp;h=dfad533c8898ff3d79067d5f16c6869803e21e12;hp=f013a25361366bfecbecdccf0dd1d00c7805d16e;hb=615301e57c25e241356a9c2380648d117709458d;hpb=510b1cfc25cd79391d6973ca20c5ec25fb1bb3b2 diff --git a/commandoptionparser.cpp b/commandoptionparser.cpp index f013a25..dfad533 100644 --- a/commandoptionparser.cpp +++ b/commandoptionparser.cpp @@ -8,7 +8,6 @@ */ -#include "globaldata.hpp" #include "commandoptionparser.hpp" @@ -16,23 +15,26 @@ //This Function parses through the command line and pulls out the command then sends the options to the parseGlobalData CommandOptionParser::CommandOptionParser(string input){ try { + m = MothurOut::getInstance(); + int openParen = input.find_first_of('('); int closeParen = input.find_last_of(')'); optionString = ""; commandString = ""; - if(openParen != -1 && closeParen != -1){ - commandString = input.substr(0, openParen); //commandString contains everything before "(" + if(openParen != -1 && closeParen != -1){ + //gobble extra spaces + int spot = 0; + for (int i = 0; i < input.length(); i++) { if (!(isspace(input[i]))) { spot = i; break; } } + if (spot > openParen) { spot = 0; } + commandString = input.substr(spot, openParen-spot); //commandString contains everything before "(" optionString = input.substr((openParen+1), (closeParen-openParen-1)); //optionString contains everything between "(" and ")". } - else if (openParen == -1) { mothurOut("You are missing ("); mothurOutEndLine(); } - else if (closeParen == -1) { mothurOut("You are missing )"); mothurOutEndLine(); } - - //GlobalData* globaldata = GlobalData::getInstance(); - //globaldata->parseGlobalData(commandString, optionString); //parser to separate and check options - } + else if (openParen == -1) { m->mothurOut("[ERROR]: You are missing ("); m->mothurOutEndLine(); } + else if (closeParen == -1) { m->mothurOut("[ERROR]:You are missing )"); m->mothurOutEndLine(); } + } catch(exception& e) { - errorOut(e, "CommandOptionParser", "CommandOptionParser"); + m->errorOut(e, "CommandOptionParser", "CommandOptionParser"); exit(1); } }