diff options
Diffstat (limited to 'src/arg-handler.cpp')
| -rw-r--r-- | src/arg-handler.cpp | 42 |
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 +} |
