From 8c01f1507616c039997619c9ea26f3e38b33736d Mon Sep 17 00:00:00 2001 From: Thomas Geissl Date: Wed, 5 Aug 2020 11:19:46 +0200 Subject: [PATCH] added version option --- commandLine/src/defines.h | 4 ++++ commandLine/src/main.cpp | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 commandLine/src/defines.h diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h new file mode 100644 index 00000000..da590805 --- /dev/null +++ b/commandLine/src/defines.h @@ -0,0 +1,4 @@ +#define OFPROJECTGENERATOR_MAJOR_VERSION 0 +#define OFPROJECTGENERATOR_MINOR_VERSION 11 +#define OFPROJECTGENERATOR_PATCH_VERSION 0 + diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index 07d67a7a..7a742565 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -1,6 +1,7 @@ #include "ofMain.h" #include "optionparser.h" -enum optionIndex { UNKNOWN, HELP, PLUS, RECURSIVE, LISTTEMPLATES, PLATFORMS, ADDONS, OFPATH, VERBOSE, TEMPLATE, DRYRUN }; +#include "defines.h" +enum optionIndex { UNKNOWN, HELP, PLUS, RECURSIVE, LISTTEMPLATES, PLATFORMS, ADDONS, OFPATH, VERBOSE, TEMPLATE, DRYRUN, VERSION }; constexpr option::Descriptor usage[] = { {UNKNOWN, 0, "", "",option::Arg::None, "Options:\n" }, @@ -13,6 +14,7 @@ constexpr option::Descriptor usage[] = {VERBOSE, 0,"v","verbose",option::Arg::None, " --verbose, -v \trun verbose" }, {TEMPLATE, 0,"t","template",option::Arg::Optional, " --template, -t \tproject template" }, {DRYRUN, 0,"d","dryrun",option::Arg::None, " --dryrun, -d \tdry run, don't change files" }, + {VERSION, 0, "w", "version", option::Arg::None, " --version, -d \treturn the current version"}, {0,0,0,0,0,0} }; @@ -79,6 +81,10 @@ void consoleSpace() { std::cout << std::endl; } +void printVersion() +{ + std::cout << OFPROJECTGENERATOR_MAJOR_VERSION << "." << OFPROJECTGENERATOR_MINOR_VERSION << "." << OFPROJECTGENERATOR_PATCH_VERSION << std::endl; +} bool printTemplates() { @@ -385,6 +391,10 @@ int main(int argc, char* argv[]){ if (options[DRYRUN].count() > 0){ bDryRun = true; } + if (options[VERSION].count() > 0){ + printVersion(); + return EXIT_OK; + } if (options[VERBOSE].count() > 0){ bVerbose = true;