-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
86 lines (66 loc) · 2.22 KB
/
main.cpp
File metadata and controls
86 lines (66 loc) · 2.22 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <QApplication>
#include <QCommandLineParser>
#include <QDir>
#include <QObject>
#include "appcore.h"
#include "defines.h"
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QApplication::setApplicationName("Updatus");
QApplication::setApplicationVersion(VERSION);
QCommandLineParser parser;
parser.setApplicationDescription("UpdateManager");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption confFileOpt(
QStringList() << "c" << "conffile",
QObject::tr("main", "Set configuration file to <configfile.cnf>."),
QObject::tr("main", "configfile"),
QString("./Updatus.cnf")
);
parser.addOption(confFileOpt);
QCommandLineOption showLogOpt(
QStringList()<<"l"<<"log",
QObject::tr("main", "Show log in console")
);
parser.addOption(showLogOpt);
QCommandLineOption guiOpt(
QStringList()<<"g"<<"nogui",
QObject::tr("main", "Not show GUI")
);
parser.addOption(guiOpt);
QCommandLineOption autoQuitOpt(
QStringList()<<"q"<<"noquit",
QObject::tr("main", "No quit after complete")
);
parser.addOption(autoQuitOpt);
QCommandLineOption showInstallOpt(
QStringList()<<"s"<<"showinstall",
QObject::tr("main", "Only show was packets will be installed.")
);
parser.addOption(showInstallOpt);
parser.process(app);
Logger::instance();
Logger::instance().setQDebugWrapper();
if ( parser.isSet(showLogOpt) ) {
Logger::instance().showLog = true;
}
AppCore * core = new AppCore(nullptr);
if ( !parser.isSet(guiOpt) ) {
core->withGui();
}
if ( !parser.isSet(autoQuitOpt) ) {
core->autoQuit(true);
}
if ( parser.isSet(showInstallOpt) ) {
core->onlyShowInstall(true);
}
QString confFilePath = ( parser.isSet(confFileOpt) )? parser.value(confFileOpt) : QApplication::applicationDirPath()+QDir::separator()+parser.value(confFileOpt);
bool upgrdSt = core->upgrade(confFilePath);
if ( !upgrdSt && parser.isSet(guiOpt) ) { //-- Если не удалось и без GUI - сразу выходим
return -1;
}
return app.exec();
}