if(argc>1){
input = argv[1];
- //m->mothurOut("input = " + input); m->mothurOutEndLine();
+ m->mothurOut("input = " + input); m->mothurOutEndLine();
if (input[0] == '#') {
m->mothurOutJustToLog("Script Mode");
lineLabel = validParameter.validFile(parameters, "label", false); if (lineLabel == "not found") { lineLabel = ""; }
- sensSpecFileName = listFile.substr(0,listFile.find_last_of('.')) + ".sensspec";
+ sensSpecFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + ".sensspec";
}
}
catch(exception& e) {
commandFactory = CommandFactory::getInstance();
+ m->mothurOut("Mothur's directories:"); m->mothurOutEndLine();
+
//redirect output
if ((output == "clear") || (output == "")) { output = ""; commandFactory->setOutputDirectory(output); }
else if (output == "default") {
string exepath = m->argv;
output = exepath.substr(0, (exepath.find_last_of('m')));
- m->mothurOut("Changing output directory to " + output); m->mothurOutEndLine();
+ m->mothurOut("outputDir=" + output); m->mothurOutEndLine();
commandFactory->setOutputDirectory(output);
}else {
//add / to name if needed
}else{
out.close();
remove(outTemp.c_str());
- m->mothurOut("Changing output directory to " + output); m->mothurOutEndLine();
+ m->mothurOut("outputDir=" + output); m->mothurOutEndLine();
commandFactory->setOutputDirectory(output);
}
}
string exepath = m->argv;
input = exepath.substr(0, (exepath.find_last_of('m')));
- m->mothurOut("Changing input directory to " + input); m->mothurOutEndLine();
+ m->mothurOut("inputDir=" + input); m->mothurOutEndLine();
commandFactory->setInputDirectory(input);
}else {
//add / to name if needed
}else{
in.close();
remove(inTemp.c_str());
- m->mothurOut("Changing input directory to " + input); m->mothurOutEndLine();
+ m->mothurOut("inputDir=" + input); m->mothurOutEndLine();
commandFactory->setInputDirectory(input);
}
}
if (tempdefault == "clear") {
#ifdef MOTHUR_FILES
string temp = MOTHUR_FILES;
- m->mothurOut("Resetting default directory to " + temp); m->mothurOutEndLine();
+ m->mothurOut("tempDefault=" + temp); m->mothurOutEndLine();
m->setDefaultPath(temp);
#else
string temp = "";
string exepath = m->argv;
tempdefault = exepath.substr(0, (exepath.find_last_of('m')));
- m->mothurOut("Changing default directory to " + tempdefault); m->mothurOutEndLine();
+ m->mothurOut("tempDefault=" + tempdefault); m->mothurOutEndLine();
m->setDefaultPath(tempdefault);
}else {
//add / to name if needed
if (lastChar != "\\") { tempdefault += "\\"; }
#endif
- m->mothurOut("Changing default directory to " + tempdefault); m->mothurOutEndLine();
+ m->mothurOut("tempDefault=" + tempdefault); m->mothurOutEndLine();
m->setDefaultPath(tempdefault);
}
public:
SetLogFileCommand(string);
- SetLogFileCommand() { abort = true; calledHelp = true; }
+ SetLogFileCommand() { setParameters(); abort = true; calledHelp = true; }
~SetLogFileCommand(){}
vector<string> setParameters();
#include "systemcommand.h"
-
+//**********************************************************************************************************************
+vector<string> SystemCommand::setParameters(){
+ try {
+ CommandParameter pcommand("command", "String", "", "", "", "", "",false,false); parameters.push_back(pcommand);
+
+ vector<string> 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 {
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<string> myArray = setParameters();
+
+ OptionParser parser(option);
+ map<string, string> parameters = parser.getParameters();
+ map<string, string>::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(',');
public:
SystemCommand(string);
- SystemCommand() { abort = true; calledHelp = true; }
+ SystemCommand() { setParameters(); abort = true; calledHelp = true; }
~SystemCommand(){}
- vector<string> setParameters() { return outputNames; } //dummy does not do anything
+ vector<string> setParameters();
string getCommandName() { return "system"; }
string getCommandCategory() { return "General"; }
string getHelpString();