Skip to content

Commit da2db02

Browse files
authored
Merge pull request #249 from thomasgeissl/feature/version-noformatting
added version option
2 parents 1dcf397 + 8c01f15 commit da2db02

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

commandLine/src/defines.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define OFPROJECTGENERATOR_MAJOR_VERSION 0
2+
#define OFPROJECTGENERATOR_MINOR_VERSION 11
3+
#define OFPROJECTGENERATOR_PATCH_VERSION 0
4+

commandLine/src/main.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "ofMain.h"
22
#include "optionparser.h"
3-
enum optionIndex { UNKNOWN, HELP, PLUS, RECURSIVE, LISTTEMPLATES, PLATFORMS, ADDONS, OFPATH, VERBOSE, TEMPLATE, DRYRUN };
3+
#include "defines.h"
4+
enum optionIndex { UNKNOWN, HELP, PLUS, RECURSIVE, LISTTEMPLATES, PLATFORMS, ADDONS, OFPATH, VERBOSE, TEMPLATE, DRYRUN, VERSION };
45
constexpr option::Descriptor usage[] =
56
{
67
{UNKNOWN, 0, "", "",option::Arg::None, "Options:\n" },
@@ -13,6 +14,7 @@ constexpr option::Descriptor usage[] =
1314
{VERBOSE, 0,"v","verbose",option::Arg::None, " --verbose, -v \trun verbose" },
1415
{TEMPLATE, 0,"t","template",option::Arg::Optional, " --template, -t \tproject template" },
1516
{DRYRUN, 0,"d","dryrun",option::Arg::None, " --dryrun, -d \tdry run, don't change files" },
17+
{VERSION, 0, "w", "version", option::Arg::None, " --version, -d \treturn the current version"},
1618
{0,0,0,0,0,0}
1719
};
1820

@@ -79,6 +81,10 @@ void consoleSpace() {
7981
std::cout << std::endl;
8082
}
8183

84+
void printVersion()
85+
{
86+
std::cout << OFPROJECTGENERATOR_MAJOR_VERSION << "." << OFPROJECTGENERATOR_MINOR_VERSION << "." << OFPROJECTGENERATOR_PATCH_VERSION << std::endl;
87+
}
8288

8389
bool printTemplates() {
8490

@@ -385,6 +391,10 @@ int main(int argc, char* argv[]){
385391
if (options[DRYRUN].count() > 0){
386392
bDryRun = true;
387393
}
394+
if (options[VERSION].count() > 0){
395+
printVersion();
396+
return EXIT_OK;
397+
}
388398

389399
if (options[VERBOSE].count() > 0){
390400
bVerbose = true;

0 commit comments

Comments
 (0)