Skip to content

Commit

Permalink
MAIN: Add a --version command line flag
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jul 29, 2013
1 parent e5716a6 commit 398dca2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@

#include "common/ustring.h"
#include "common/util.h"
#include "common/version.h"

#include "common/configman.h"

static void displayUsage(const char *name) {
std::printf("Usage: %s [options] [target]\n\n", name);
std::printf(" --help This text\n");
std::printf(" --version Display version information and exit\n");
std::printf(" -cFILE --config=FILE Load the config from file FILE\n");
std::printf(" -pDIR --path=DIR Override the game path with DIR\n");
std::printf(" -wSIZE --width=SIZE Set the window's width to SIZE\n");
Expand Down Expand Up @@ -78,6 +80,10 @@ static void displayUsage(const char *name) {
std::printf("\n");
}

static void displayVersion() {
std::printf("%s\n", XOREOS_NAMEVERSIONFULL);
}

static Common::UString convertShortToLongOption(char shortOption) {
if (shortOption == 'p')
return "path";
Expand Down Expand Up @@ -196,6 +202,12 @@ bool parseCommandline(int argc, char **argv, Common::UString &target, int &code)
return false;
}

if (!strcmp(argv[i], "--version")) {
code = 0;
displayVersion();
return false;
}

if (!parseOption(argv[i], key)) {
code = 1;
return false;
Expand Down

0 comments on commit 398dca2

Please sign in to comment.