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
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#include "command_line_options.h"
#include <getopt.h>
#include <QDebug>
CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) {
// parse command line arguments (please sort by short option for easier handling)
static const struct option longOptions[] = {
{"base", required_argument, NULL, 'b'},
{"path", required_argument, NULL, 'b'}, // Compatibility to v1.0
{"config", required_argument, NULL, 'c'},
{"debug", no_argument, NULL, 'D'},
{"default", required_argument, NULL, 'd'},
{"fullscreen", no_argument, NULL, 'F'},
{"file", required_argument, NULL, 'f'},
{"help", no_argument, NULL, 'h'},
{"locations", required_argument, NULL, 'l'},
{"pool", required_argument, NULL, 'P'},
{"pvs", no_argument, NULL, 'p'},
{"runscript", no_argument, NULL, 'S'},
{"size", required_argument, NULL, 's'},
{"tab", required_argument, NULL, 'T'},
{"theme", required_argument, NULL, 't'},
{"url", required_argument, NULL, 'u'},
{"version", no_argument, NULL, 'v'},
{"xpath", required_argument, NULL, 'x'},
{"location-mode", required_argument, NULL, 'locm'},
{"template-mode", required_argument, NULL, 'tmpm'},
{0, 0, 0, 0}
};
int c;
// Again, please sort alphabetically in getopt_long call and switch statement
while ((c = getopt_long(argc, argv, "b:c:Dd:Ff:hl:P:pSs:t:T:u:vx:?", longOptions, NULL)) != -1) {
switch (c) {
case 'b':
options.insert("base", optarg);
break;
case 'c':
options.insert("config", optarg);
break;
case 'D':
options.insert("debugMode", "debugMode");
break;
case 'd':
options.insert("default", optarg);
break;
case 'F':
options.insert("fullscreen", "fullscreen");
break;
case 'f':
options.insert("file", optarg);
break;
case 'h':
case '?':
options.insert("usage", "usage");
break;
case 'l':
options.insert("locations", optarg);
break;
case 'p':
options.insert("pvs", "pvs");
break;
case 'P':
options.insert("pool", optarg);
break;
case 'S':
options.insert("runscript", optarg);
break;
case 's':
options.insert("size", optarg);
break;
case 't':
options.insert("theme", optarg);
break;
case 'T':
options.insert("tab", optarg);
break;
case 'u':
options.insert("url", optarg);
break;
case 'v':
options.insert("version", "version");
break;
case 'x':
options.insert("xpath", optarg);
break;
case 'locm':
options.insert("location-mode", optarg);
break;
case 'tmpm':
options.insert("template-mode", optarg);
break;
default:
options.insert("error", "error");
break;
}
}
}
|