forked from ultmaster/runexe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntryPoint.cpp
48 lines (34 loc) · 1.44 KB
/
EntryPoint.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "Run.h"
#include "Interaction.h"
#include "Process.h"
#include "Strings.h"
using namespace runexe;
using namespace std;
int main(int argc, char *argv[]) {
InvocationParams invocationParams = processCommandLine(argc, argv);
Configuration &configuration = Configuration::getConfiguration();
const string &interactorCommandLine = configuration.getInteractor();
vector<InvocationResult> results;
if (!interactorCommandLine.empty()) {
// interactive mode
InvocationParams interactorParams = InvocationParams(Strings::tokenizeCommandLine(interactorCommandLine));
interactorParams.setProgramName("interactor");
results = interaction::interact(invocationParams, interactorParams);
} else {
// normal mode
ProcessParams params = invocationParams.asProcessParams();
ProcessOutcome outcome = run(params);
results.push_back(InvocationResult(outcome));
if (invocationParams.getRedirectOutput().empty())
remove(outcome.output_file.c_str());
if (invocationParams.getRedirectError().empty())
remove(outcome.error_file.c_str());
}
if (configuration.isScreenOutput()) {
for (size_t i = 0; i < results.size(); ++i)
printInvocationResult(invocationParams, results[i]);
}
if (configuration.isXmlOutput())
printXmlInvocationResult(results, configuration.getXmlFileName());
return EXIT_SUCCESS;
}