summaryrefslogtreecommitdiff
path: root/src/arg-handler.cpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-12-18 20:35:37 -0500
committerJonathan Bradley <jcb@pikum.xyz>2023-12-23 11:41:03 -0500
commitc7c678651a30db30e449e965e6c82ad0dcb871e6 (patch)
tree09f012460a7f77bb92d82d642ec0e9d85ef347e2 /src/arg-handler.cpp
parent4c4304429a4c06167aa21de246aa21e7b3ceb725 (diff)
checkpoint - arg-handler
Diffstat (limited to 'src/arg-handler.cpp')
-rw-r--r--src/arg-handler.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/arg-handler.cpp b/src/arg-handler.cpp
new file mode 100644
index 0000000..1b40039
--- /dev/null
+++ b/src/arg-handler.cpp
@@ -0,0 +1,42 @@
+
+#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[] = {
+ {"plugin", required_argument, 0, 'p'},
+ {0, 0, 0, 0},
+ };
+
+ int optionIndex = 0;
+ int c = getopt_long(argc, argv, "p:", long_options, &optionIndex);
+ if (c == -1) {
+ break;
+ }
+
+ switch (c) {
+ case 0:
+ break;
+ case 'p':
+ pkeSettings.pluginPath = 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
+}