diff --git a/adapters/standalone.cpp b/adapters/standalone.cpp index 596bd0c5..57a9a59b 100644 --- a/adapters/standalone.cpp +++ b/adapters/standalone.cpp @@ -24,13 +24,13 @@ #include #include -#include -#include +#include #include // for getopt #include // for signal #if defined ARCH_WIN #include // for CreateMutex #endif +#include #if defined ARCH_MAC #define GLFW_EXPOSE_NATIVE_COCOA @@ -73,9 +73,20 @@ int main(int argc, char* argv[]) { float screenshotZoom = 1.f; // Parse command line arguments + static const struct option longOptions[] = { + {"safe", no_argument, NULL, 'a'}, + {"dev", no_argument, NULL, 'd'}, + {"headless", no_argument, NULL, 'h'}, + {"screenshot", required_argument, NULL, 't'}, + {"system", required_argument, NULL, 's'}, + {"user", required_argument, NULL, 'u'}, + {"version", no_argument, NULL, 'v'}, + {NULL, 0, NULL, 0} + }; int c; opterr = 0; - while ((c = getopt(argc, argv, "adht:s:u:p:")) != -1) { + + while ((c = getopt_long(argc, argv, "adht:s:u:vp:", longOptions, NULL)) != -1) { switch (c) { case 'a': { settings::safeMode = true; @@ -96,6 +107,10 @@ int main(int argc, char* argv[]) { case 'u': { asset::userDir = optarg; } break; + case 'v': { + std::fprintf(stderr, "%s %s %s %s\n", APP_NAME.c_str(), APP_EDITION_NAME.c_str(), APP_VERSION.c_str(), APP_ARCH.c_str()); + return 0; + } // Mac "app translocation" passes a nonsense -psn_... flag, so -p is reserved. case 'p': break; default: break;