| 1 |
#include "clConsoleCMD.h" |
| 2 |
|
| 3 |
#include "dirsaver.h" |
| 4 |
|
| 5 |
#include <wx/filename.h> |
| 6 |
#include <wx/utils.h> |
| 7 |
|
| 8 |
clConsoleCMD::clConsoleCMD() {} |
| 9 |
|
| 10 |
clConsoleCMD::~clConsoleCMD() {} |
| 11 |
|
| 12 |
bool clConsoleCMD::Start() |
| 13 |
{ |
| 14 |
DirSaver ds; // restore the directory upon exiting this function |
| 15 |
wxFileName fn(GetWorkingDirectory(), ""); |
| 16 |
if(fn.DirExists()) { |
| 17 |
::wxSetWorkingDirectory(fn.GetPath()); |
| 18 |
} |
| 19 |
return StartProcess(PrepareCommand()); |
| 20 |
} |
| 21 |
|
| 22 |
bool clConsoleCMD::StartForDebugger() { return false; } |
| 23 |
|
| 24 |
wxString clConsoleCMD::PrepareCommand() |
| 25 |
{ |
| 26 |
// no args? just return the cmd command |
| 27 |
wxString command = WrapWithQuotesIfNeeded(GetCommand()); |
| 28 |
if(command.empty()) { |
| 29 |
return "cmd"; |
| 30 |
} |
| 31 |
|
| 32 |
// Build the command to execute |
| 33 |
wxString commandToExecute; |
| 34 |
|
| 35 |
wxString rest_cmd; |
| 36 |
// if "wait-when-done" enabled, wrap the command with codelite-exec |
| 37 |
if(IsWaitWhenDone()) { |
| 38 |
wxFileName fnCodeliteExec(clStandardPaths::Get().GetBinaryFullPath("codelite-exec")); |
| 39 |
wxString strCodeLiteExec = WrapWithQuotesIfNeeded(fnCodeliteExec.GetFullPath()); |
| 40 |
rest_cmd << strCodeLiteExec << " "; |
| 41 |
} |
| 42 |
|
| 43 |
// append the command to run |
| 44 |
rest_cmd << command; |
| 45 |
if(!GetCommandArgs().IsEmpty()) { |
| 46 |
rest_cmd << " " << GetCommandArgs(); |
| 47 |
} |
| 48 |
return commandToExecute + rest_cmd; |
| 49 |
} |