X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=setlogfilecommand.cpp;h=128c5671ed55712d2293e0b3c3959da17a7e9f05;hp=b99b833a5651c80d4b54b1d957810303fe65b199;hb=a8e2df1b96a57f5f29576b08361b86a96a8eff4f;hpb=8bc3e5b38c2317a1715f53be22fa96455868c281 diff --git a/setlogfilecommand.cpp b/setlogfilecommand.cpp index b99b833..128c567 100644 --- a/setlogfilecommand.cpp +++ b/setlogfilecommand.cpp @@ -9,38 +9,37 @@ #include "setlogfilecommand.h" + //********************************************************************************************************************** -vector SetLogFileCommand::getValidParameters(){ +vector SetLogFileCommand::setParameters(){ try { - string Array[] = {"name","append","outputdir","inputdir"}; - vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + CommandParameter pappend("append", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pappend); + CommandParameter pname("name", "String", "", "", "", "", "","",false,true,true); parameters.push_back(pname); + CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir); + CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir); + + vector myArray; + for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } return myArray; } catch(exception& e) { - m->errorOut(e, "SetLogFileCommand", "getValidParameters"); + m->errorOut(e, "SetLogFileCommand", "setParameters"); exit(1); } } //********************************************************************************************************************** -vector SetLogFileCommand::getRequiredParameters(){ +string SetLogFileCommand::getHelpString(){ try { - string Array[] = {"name"}; - vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); - return myArray; + string helpString = ""; + helpString += "The set.logfile command can be used to provide a specific name for your logfile and/or to append the log generated by mothur to an existing file.\n"; + helpString += "The set.logfile command parameters are name and append, name is required. Append is set to false by default.\n"; + helpString += "The set.logfile command should be in the following format: set.logfile(name=yourLogFileName, append=T).\n"; + helpString += "Example set.logfile(name=/Users/lab/desktop/output.txt, append=T).\n"; + helpString += "Note: No spaces between parameter labels (i.e. name), '=' and parameters (i.e.yourLogFileName).\n"; + return helpString; } catch(exception& e) { - m->errorOut(e, "SetLogFileCommand", "getRequiredParameters"); - exit(1); - } -} -//********************************************************************************************************************** -vector SetLogFileCommand::getRequiredFiles(){ - try { - vector myArray; - return myArray; - } - catch(exception& e) { - m->errorOut(e, "SetLogFileCommand", "getRequiredFiles"); + m->errorOut(e, "SetLogFileCommand", "getHelpString"); exit(1); } } @@ -48,15 +47,14 @@ vector SetLogFileCommand::getRequiredFiles(){ SetLogFileCommand::SetLogFileCommand(string option) { try { - abort = false; + abort = false; calledHelp = false; //allow user to run help - if(option == "help") { help(); abort = true; } + if(option == "help") { help(); abort = true; calledHelp = true; } + else if(option == "citation") { citation(); abort = true; calledHelp = true;} else { - //valid paramters for this command - string Array[] = {"name","append","outputdir","inputdir"}; - vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + vector myArray = setParameters(); OptionParser parser(option); map parameters = parser.getParameters(); @@ -79,31 +77,13 @@ SetLogFileCommand::SetLogFileCommand(string option) { exit(1); } } -//********************************************************************************************************************** - -void SetLogFileCommand::help(){ - try { - m->mothurOut("The set.logfile command can be used to provide a specific name for your logfile and/or to append the log generated by mothur to an existing file.\n"); - m->mothurOut("The set.logfile command parameters are name and append, name is required. Append is set to false by default.\n"); - m->mothurOut("The set.logfile command should be in the following format: set.logfile(name=yourLogFileName, append=T).\n"); - m->mothurOut("Example set.logfile(name=/Users/lab/desktop/output.txt, append=T).\n"); - m->mothurOut("Note: No spaces between parameter labels (i.e. name), '=' and parameters (i.e.yourLogFileName).\n\n"); - } - catch(exception& e) { - m->errorOut(e, "SetLogFileCommand", "help"); - exit(1); - } -} -//********************************************************************************************************************** - -SetLogFileCommand::~SetLogFileCommand(){} //********************************************************************************************************************** int SetLogFileCommand::execute(){ try { - if (abort == true) { return 0; } + if (abort == true) { if (calledHelp) { return 0; } return 2; } commandFactory = CommandFactory::getInstance();