2 * commandoptionparser.cpp
5 * Created by Pat Schloss on 10/23/08.
6 * Copyright 2008 Patrick D. Schloss. All rights reserved.
11 #include "commandoptionparser.hpp"
14 //**********************************************************************************************************************
15 //This Function parses through the command line and pulls out the command then sends the options to the parseGlobalData
16 CommandOptionParser::CommandOptionParser(string input){
18 m = MothurOut::getInstance();
20 int openParen = input.find_first_of('(');
21 int closeParen = input.find_last_of(')');
25 if(openParen != -1 && closeParen != -1){
28 for (int i = 0; i < input.length(); i++) { if (!(isspace(input[i]))) { spot = i; break; } }
29 if (spot > openParen) { spot = 0; }
30 commandString = input.substr(spot, openParen-spot); //commandString contains everything before "("
31 optionString = input.substr((openParen+1), (closeParen-openParen-1)); //optionString contains everything between "(" and ")".
33 else if (openParen == -1) { m->mothurOut("[ERROR]: You are missing ("); m->mothurOutEndLine(); }
34 else if (closeParen == -1) { m->mothurOut("[ERROR]:You are missing )"); m->mothurOutEndLine(); }
37 m->errorOut(e, "CommandOptionParser", "CommandOptionParser");
42 //**********************************************************************************************************************
44 string CommandOptionParser::getCommandString() { return commandString; }
46 //**********************************************************************************************************************
48 string CommandOptionParser::getOptionString() { return optionString; }
50 //**********************************************************************************************************************