X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getcurrentcommand.cpp;h=b9b907d903752d8a93979680d361c2ea683c7cab;hb=9a808b553f14a25f9c5e94da92a7077a57054e8e;hp=bd7539a25a30a2c972dfa9157a1b25ceb3349c33;hpb=348de0f8b17d84ede77081dcf67bd6ef43496677;p=mothur.git diff --git a/getcurrentcommand.cpp b/getcurrentcommand.cpp index bd7539a..b9b907d 100644 --- a/getcurrentcommand.cpp +++ b/getcurrentcommand.cpp @@ -9,48 +9,46 @@ #include "getcurrentcommand.h" - //********************************************************************************************************************** -vector GetCurrentCommand::getValidParameters(){ +vector GetCurrentCommand::setParameters(){ try { - string Array[] = {"outputdir","inputdir","clear"}; - vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + CommandParameter pclear("clear", "String", "", "", "", "", "","",false,false); parameters.push_back(pclear); + 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, "GetCurrentCommand", "getValidParameters"); + m->errorOut(e, "GetCurrentCommand", "setParameters"); exit(1); } } //********************************************************************************************************************** -GetCurrentCommand::GetCurrentCommand(){ +string GetCurrentCommand::getHelpString(){ try { - abort = true; calledHelp = true; + string helpString = ""; + helpString += "The get.current command outputs the current files saved by mothur.\n"; + helpString += "The get.current command has one parameter: clear.\n"; + helpString += "The clear paramter is used to indicate which file types you would like to clear values for, multiple types can be separated by dashes.\n"; + helpString += "The get.current command should be in the following format: \n"; + helpString += "get.current() or get.current(clear=fasta-name-accnos)\n"; + return helpString; } catch(exception& e) { - m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand"); + m->errorOut(e, "GetCurrentCommand", "getHelpString"); exit(1); } } //********************************************************************************************************************** -vector GetCurrentCommand::getRequiredParameters(){ +GetCurrentCommand::GetCurrentCommand(){ try { - vector myArray; - return myArray; + abort = true; calledHelp = true; + setParameters(); } catch(exception& e) { - m->errorOut(e, "GetCurrentCommand", "getRequiredParameters"); - exit(1); - } -} -//********************************************************************************************************************** -vector GetCurrentCommand::getRequiredFiles(){ - try { - vector myArray; - return myArray; - } - catch(exception& e) { - m->errorOut(e, "GetCurrentCommand", "getRequiredFiles"); + m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand"); exit(1); } } @@ -61,11 +59,10 @@ GetCurrentCommand::GetCurrentCommand(string option) { //allow user to run help 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[] = {"outputdir","inputdir","clear"}; - vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + vector myArray = setParameters(); OptionParser parser(option); map parameters = parser.getParameters(); @@ -89,30 +86,13 @@ GetCurrentCommand::GetCurrentCommand(string option) { } //********************************************************************************************************************** -void GetCurrentCommand::help(){ - try { - m->mothurOut("The get.current command outputs the current files saved by mothur.\n"); - m->mothurOut("The get.current command has one parameter: clear.\n"); - m->mothurOut("The clear paramter is used to indicate which file types you would like to clear values for, multiple types can be separated by dashes.\n"); - m->mothurOut("The get.current command should be in the following format: \n"); - m->mothurOut("get.current() or get.current(clear=fasta-name-accnos)\n"); - - } - catch(exception& e) { - m->errorOut(e, "GetCurrentCommand", "help"); - exit(1); - } -} - -//********************************************************************************************************************** -GetCurrentCommand::~GetCurrentCommand(){} -//********************************************************************************************************************** - int GetCurrentCommand::execute(){ try { if (abort == true) { if (calledHelp) { return 0; } return 2; } - + + cFactory = CommandFactory::getInstance(); + //user wants to clear a type if (types.size() != 0) { for (int i = 0; i < types.size(); i++) { @@ -157,7 +137,17 @@ int GetCurrentCommand::execute(){ }else if (types[i] == "accnos") { m->setAccnosFile(""); }else if (types[i] == "taxonomy") { - m->setTaxonomyFile(""); + m->setTaxonomyFile(""); + }else if (types[i] == "flow") { + m->setFlowFile(""); + }else if (types[i] == "biom") { + m->setBiomFile(""); + }else if (types[i] == "count") { + m->setCountTableFile(""); + }else if (types[i] == "summary") { + m->setSummaryFile(""); + }else if (types[i] == "processors") { + m->setProcessors("1"); }else if (types[i] == "all") { m->clearCurrentFiles(); }else { @@ -166,10 +156,35 @@ int GetCurrentCommand::execute(){ } } - m->mothurOutEndLine(); m->mothurOut("Current files saved by mothur:"); m->mothurOutEndLine(); - m->printCurrentFiles(); + if (m->hasCurrentFiles()) { + m->mothurOutEndLine(); m->mothurOut("Current files saved by mothur:"); m->mothurOutEndLine(); + m->printCurrentFiles(); + } + + string inputDir = cFactory->getInputDir(); + if (inputDir != "") { + m->mothurOutEndLine(); m->mothurOut("Current input directory saved by mothur: " + inputDir); m->mothurOutEndLine(); + } + + string outputDir = cFactory->getOutputDir(); + if (outputDir != "") { + m->mothurOutEndLine(); m->mothurOut("Current output directory saved by mothur: " + outputDir); m->mothurOutEndLine(); + } + string defaultPath = m->getDefaultPath(); + if (defaultPath != "") { + m->mothurOutEndLine(); m->mothurOut("Current default directory saved by mothur: " + defaultPath); m->mothurOutEndLine(); + } + + + string temp = "./"; +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) +#else + temp = ".\\"; +#endif + temp = m->getFullPathName(temp); + m->mothurOutEndLine(); m->mothurOut("Current working directory: " + temp); m->mothurOutEndLine(); - return 0; + return 0; } catch(exception& e) {