-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
45 lines (37 loc) · 1.33 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
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#include "mainwindow.h"
#include "projectparser.h"
int main(int argc, char *argv[])
{
QCoreApplication::setOrganizationName("MM");
QCoreApplication::setApplicationName("QtWidgetsStateLoaderGenerator");
QCoreApplication::setApplicationVersion("1.0");
QApplication a(argc, argv);
QCommandLineParser parser;
parser.addHelpOption();
// An option with a value
QCommandLineOption projectOption(QStringList() << "p" << "project",
QCoreApplication::translate("main", "Regenerates the code accoding to the project file."),
QCoreApplication::translate("main", "projectfile"));
parser.addOption(projectOption);
// Process the actual command line arguments given by the user
parser.process(a);
QString projectPath = parser.value(projectOption);
if (projectPath.isEmpty()) {
MainWindow w;
w.show();
return a.exec();
} else {
ProjectParser p;
p.parseProject(projectPath);
if (p.generate()) {
qDebug() << QCoreApplication::translate("main", "Code generation was successful");
return 0;
} else {
qDebug() << QCoreApplication::translate("main", "Code generation failed: %1").arg(p.error());
return -1;
}
}
}