-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
57 lines (47 loc) · 1.88 KB
/
main.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
48
49
50
51
52
53
54
55
#include <ReFacE.h>
static void show_usage(std::string name) {
std::cout << "Usage: " << name << " <option(s)> SOURCES\n"
<< "Options:\n"
<< "\t-h,--help\t\t\t\t\tShow this help message\n"
<< "\t<MAIN_CONFIG_FILE>\t\t\t\tRun the program using the MAIN_CONFIG_FILE configuration file."
<< std::endl;
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
if(DEBUG){cout << "Main Starting...\n";}
//Files declaration
std::string mainConfigFile;
//#############################################################################################
// COMMAND LINE PARSER
//#############################################################################################
// Checking Command Line Arguments //
if (argc < 2) {
std::cout << argv[0] << " invalid option!\nTry '"<< argv[0]
<< " --help' for more information.\n";
return -1;
}
mainConfigFile = argv[1];
// Command HELP --> Without flags (it's a sovereign command) //
if ((mainConfigFile == "-h") || (mainConfigFile == "--help")) {
show_usage("ReFacE");
return 0;
}
//#############################################################################################
// END OF PARSER
//#############################################################################################
MainController *mainControl = new MainController();
if(DEBUG){cout << "Main Config...\n";}
if(mainControl->config(mainConfigFile) != 0){
cerr << "Something went wrong on MainController::config()! Please Check it!\n";
delete mainControl;
return -1;
}
if(mainControl->run() != 0){
cerr << "Something went wrong on MainController::run()! Please Check it!\n";
delete mainControl;
return -1;
}
delete mainControl;
return 0;
}