X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=systemcommand.cpp;h=6a1e3555f80ffd3f6f5a1565296faf4072995629;hb=9d6f36294dcaef3ac65a0e69fd8140077c3209e0;hp=6b0a6d06474809f16fae1a0c17338ef1f7458dc7;hpb=f0a594f6676ef5a52d1f122b6de70de2fda08c81;p=mothur.git diff --git a/systemcommand.cpp b/systemcommand.cpp index 6b0a6d0..6a1e355 100644 --- a/systemcommand.cpp +++ b/systemcommand.cpp @@ -9,7 +9,20 @@ #include "systemcommand.h" - +//********************************************************************************************************************** +vector SystemCommand::setParameters(){ + try { + CommandParameter pcommand("command", "String", "", "", "", "", "",false,false); parameters.push_back(pcommand); + + vector myArray; + for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } + return myArray; + } + catch(exception& e) { + m->errorOut(e, "SystemCommand", "setParameters"); + exit(1); + } +} //********************************************************************************************************************** SystemCommand::SystemCommand(string option) { try { @@ -19,8 +32,22 @@ SystemCommand::SystemCommand(string option) { if(option == "help") { help(); abort = true; calledHelp = true; } else { - if (option == "") { m->mothurOut("You must enter a command to run."); m->mothurOutEndLine(); abort = true; } - else { + vector myArray = setParameters(); + + OptionParser parser(option); + map parameters = parser.getParameters(); + map::iterator it; + + ValidParameters validParameter; + + //check for optional parameter and set defaults + // ...at some point should added some additional type checking... + string commandOption = validParameter.validFile(parameters, "command", false); + if (commandOption == "not found") { commandOption = ""; } + else { command = commandOption; } + + if ((option == "") && (commandOption == "")) { m->mothurOut("You must enter a command to run."); m->mothurOutEndLine(); abort = true; } + else if (commandOption == "") { //check for outputdir and inputdir parameters int commaPos = option.find_first_of(',');