From c7c678651a30db30e449e965e6c82ad0dcb871e6 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Mon, 18 Dec 2023 20:35:37 -0500 Subject: checkpoint - arg-handler --- src/arg-handler.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/arg-handler.cpp (limited to 'src/arg-handler.cpp') 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 +#include + +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 +} -- cgit v1.2.3