/
main.cpp
37 lines (30 loc) · 1.03 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
#include "mainwindow.hpp"
#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <iostream>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCoreApplication::setApplicationName("empire-gui");
// Configure parser for command line arguments
QCommandLineParser parser;
parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
parser.addHelpOption();
QCommandLineOption modeOption("obs", "Start the client as observer.");
parser.addOption(modeOption);
QCommandLineOption addressOption("saddr", "Server address.", "port", "localhost");
parser.addOption(addressOption);
QCommandLineOption portOption("sport", "Server port.", "port", "0");
parser.addOption(portOption);
// Get arguments values
parser.process(a);
MainWindow w;
// Process arguments
QStringList args = parser.positionalArguments();
QString address = parser.value("saddr");
int port = parser.value("sport").toInt();
w.initialize(address, port, parser.isSet(modeOption));
w.show();
return a.exec();
}