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
|
#include <QApplication>
#include <getopt.h>
#include "fbsplash.h"
void printHelp() {
QTextStream qout(stdout);
qout << "Usage: ./fbsplash [OPTIONS]\n";
qout << "Options:\n";
qout << "-h, --help " << "Prints this help.\n";
qout.flush();
exit( EXIT_SUCCESS);
}
int main(int argc, char *argv[]) {
QApplication app(argc, argv, QApplication::GuiServer);
app.setOrganizationName("OpenSLX");
app.setApplicationName("fbsplash");
// Command line arguements parsing
QMap<QString, QString> clOpts;
static const char *optString = "h";
static const struct option
longOpts[] = { { "help", no_argument, NULL, 'h' } };
int longIndex = 0;
int opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
while (opt != -1) {
switch (opt) {
case 'h':
clOpts.insert("help", "help");
break;
}
opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
}
if (clOpts.contains("help"))
printHelp();
// fbsplash init
fbsplash bs;
app.exec();
}
|