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
|
#include "arg-handler.hpp"
#include "game-settings.hpp"
#include <cstdio>
#include <getopt.h>
void PkeArgs_Parse(int argc, char *argv[]) {
while (1) {
static struct option long_options[] = {
{"level", required_argument, 0, 'l'},
{"plugin", required_argument, 0, 'p'},
{"project", required_argument, 0, 'r'},
{"scene", required_argument, 0, 's'},
{0, 0, 0, 0},
};
int optionIndex = 0;
int c = getopt_long(argc, argv, "", long_options, &optionIndex);
if (c == -1) {
break;
}
switch (c) {
case 0:
break;
case 'l':
pkeSettings.args.levelName = optarg;
break;
case 'p':
pkeSettings.args.pluginPath = optarg;
break;
case 'r':
pkeSettings.args.projectPath = optarg;
break;
case 's':
pkeSettings.args.sceneName = optarg;
break;
default:
fprintf(stderr, "Unused parameter: %c\n", c);
}
}
#ifndef NDEBUG
if (optind < argc) {
fprintf(stdout, "non-option args:\n");
while (optind < argc) {
fprintf(stdout, "%s ", argv[optind++]);
}
fprintf(stdout, "\n");
}
#endif
}
|