]> git.donarmstrong.com Git - mothur.git/blobdiff - engine.cpp
added parse.list command
[mothur.git] / engine.cpp
index 811236003b5089171536c7e075b10b506baf670a..18e1a595c06343a521d9bcd6458b95db4d863db7 100644 (file)
 
 #include "engine.hpp"
 
+/***********************************************************************/
+Engine::Engine(){
+       try {
+               cFactory = CommandFactory::getInstance();
+       }
+       catch(exception& e) {
+               errorOut(e, "Engine", "Engine");
+               exit(1);
+       }
+}
 
 /***********************************************************************/
 
@@ -38,14 +48,11 @@ bool InteractEngine::getInput(){
                int quitCommandCalled = 0;
                
                while(quitCommandCalled != 1){
-                       
+
                        mothurOutEndLine();
                        
                        input = getCommand();                   
                        
-                       mothurOutJustToLog("mothur > " + input);
-                       mothurOutEndLine();
-                       
                        //allow user to omit the () on the quit command
                        if (input == "quit") { input = "quit()"; }
                        
@@ -75,12 +82,36 @@ bool InteractEngine::getInput(){
 /***********************************************************************/
 string Engine::getCommand()  {
        try {
-               char* nextCommand = NULL;
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                       #ifdef USE_READLINE
+                               char* nextCommand = NULL;
+                               nextCommand = readline("mothur > ");
+                               
+                               if(nextCommand != NULL) {  add_history(nextCommand);  } 
+                               else{ //^D causes null string and we want it to quit mothur
+                                       nextCommand = "quit"; 
+                                       cout << nextCommand << endl;
+                               }       
+                               
+                               mothurOutJustToLog("mothur > " + toString(nextCommand));
+                               return nextCommand;
+                       #else
+                               string nextCommand = "";
+                               mothurOut("mothur > ");
+                               getline(cin, nextCommand);
+                               mothurOutJustToLog("mothur > " + toString(nextCommand));
+                               return nextCommand;
+                       #endif
+               #else
+                       string nextCommand = "";
+                       mothurOut("mothur > ");
+                       getline(cin, nextCommand);
+                       mothurOutJustToLog("mothur > " + toString(nextCommand));
+                       return nextCommand;
+               #endif
                
-               nextCommand = readline("mothur > ");
-               if(nextCommand != NULL) {  add_history(nextCommand);  }
+               mothurOutEndLine();
                                                
-               return nextCommand;
        }
        catch(exception& e) {
                errorOut(e, "Engine", "getCommand");
@@ -88,17 +119,6 @@ string Engine::getCommand()  {
        }
 }
 /***********************************************************************/
-void Engine::terminateCommand(int dummy)  {
-       try {
-               mothurOut("Stopping command."); mothurOutEndLine();
-               cFactory->getCommand();  //terminates command
-       }
-       catch(exception& e) {
-               errorOut(e, "Engine", "terminateCommand");
-               exit(1);
-       }
-}
-/***********************************************************************/
 //This function opens the batchfile to be used by BatchEngine::getInput.
 BatchEngine::BatchEngine(string path, string batchFileName){
        try {