2 * setlogfilecommand.cpp
5 * Created by westcott on 4/27/10.
6 * Copyright 2010 Schloss Lab. All rights reserved.
10 #include "setlogfilecommand.h"
12 //**********************************************************************************************************************
14 SetLogFileCommand::SetLogFileCommand(string option) {
18 //allow user to run help
19 if(option == "help") { help(); abort = true; }
22 //valid paramters for this command
23 string Array[] = {"name","append","outputdir","inputdir"};
24 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
26 OptionParser parser(option);
27 map<string, string> parameters = parser.getParameters();
29 ValidParameters validParameter;
30 //check to make sure all parameters are valid for command
31 for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
32 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
35 name = validParameter.validFile(parameters, "name", false);
36 if (name == "not found") { m->mothurOut("name is a required parameter for the set.logfile command."); abort = true; }
38 string temp = validParameter.validFile(parameters, "append", false); if (temp == "not found") { temp = "F"; }
39 append = isTrue(temp);
43 m->errorOut(e, "SetLogFileCommand", "SetLogFileCommand");
47 //**********************************************************************************************************************
49 void SetLogFileCommand::help(){
51 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");
52 m->mothurOut("The set.logfile command parameters are name and append, name is required. Append is set to false by default.\n");
53 m->mothurOut("The set.logfile command should be in the following format: set.logfile(name=yourLogFileName, append=T).\n");
54 m->mothurOut("Example set.logfile(name=/Users/lab/desktop/output.txt, append=T).\n");
55 m->mothurOut("Note: No spaces between parameter labels (i.e. name), '=' and parameters (i.e.yourLogFileName).\n\n");
58 m->errorOut(e, "SetLogFileCommand", "help");
62 //**********************************************************************************************************************
64 SetLogFileCommand::~SetLogFileCommand(){}
66 //**********************************************************************************************************************
68 int SetLogFileCommand::execute(){
71 if (abort == true) { return 0; }
73 commandFactory = CommandFactory::getInstance();
75 commandFactory->setLogfileName(name, append);
80 m->errorOut(e, "SetLogFileCommand", "execute");
84 //**********************************************************************************************************************/