From e43d127effaa901b6d38e63030181f90e5455c26 Mon Sep 17 00:00:00 2001 From: Eddie Scholtz Date: Fri, 29 Jan 2016 15:01:54 -0800 Subject: [PATCH 1/3] Add -v --version arg support to the flatc command. --- src/flatc.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/flatc.cpp b/src/flatc.cpp index fa8bdf343..f42baba20 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -19,6 +19,8 @@ #include "flatbuffers/util.h" #include +#define FLATC_VERSION "1.2.0" + static void Error(const std::string &err, bool usage = false, bool show_exe_name = true); @@ -97,6 +99,7 @@ static void Error(const std::string &err, bool usage, bool show_exe_name) { " -o PATH Prefix PATH to all generated files.\n" " -I PATH Search for includes in the specified path.\n" " -M Print make rules for generated files.\n" + " -v, --version Print the version number of flatc and exit.\n" " --strict-json Strict JSON: field names must be / will be quoted,\n" " no trailing commas in tables/vectors.\n" " --defaults-json Output fields whose value is the default when\n" @@ -188,6 +191,9 @@ int main(int argc, const char *argv[]) { schema_binary = true; } else if(arg == "-M") { print_make_rules = true; + } else if(arg == "-v" || arg == "--version") { + printf("flatc version %s\n", FLATC_VERSION); + exit(0); } else { for (size_t i = 0; i < num_generators; ++i) { if (arg == generators[i].generator_opt_long || From 0b3cd33e550fabdcde76739d40abf9c6c55f7fa3 Mon Sep 17 00:00:00 2001 From: Eddie Scholtz Date: Mon, 1 Feb 2016 13:43:05 -0800 Subject: [PATCH 2/3] Add __DATE__ to FLATC_VERSION based on PR feedback. --- src/flatc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flatc.cpp b/src/flatc.cpp index f42baba20..d66239c32 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -19,7 +19,7 @@ #include "flatbuffers/util.h" #include -#define FLATC_VERSION "1.2.0" +#define FLATC_VERSION "1.2.0 (" __DATE__ ")" static void Error(const std::string &err, bool usage = false, bool show_exe_name = true); From ac655b3ff0ab9a7901f03c0b2a21e57e0e564b79 Mon Sep 17 00:00:00 2001 From: Eddie Scholtz Date: Mon, 1 Feb 2016 13:54:09 -0800 Subject: [PATCH 3/3] Remove -v as option for printing version # (based on PR feedback). --- src/flatc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flatc.cpp b/src/flatc.cpp index d66239c32..a49361246 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -99,7 +99,7 @@ static void Error(const std::string &err, bool usage, bool show_exe_name) { " -o PATH Prefix PATH to all generated files.\n" " -I PATH Search for includes in the specified path.\n" " -M Print make rules for generated files.\n" - " -v, --version Print the version number of flatc and exit.\n" + " --version Print the version number of flatc and exit.\n" " --strict-json Strict JSON: field names must be / will be quoted,\n" " no trailing commas in tables/vectors.\n" " --defaults-json Output fields whose value is the default when\n" @@ -191,7 +191,7 @@ int main(int argc, const char *argv[]) { schema_binary = true; } else if(arg == "-M") { print_make_rules = true; - } else if(arg == "-v" || arg == "--version") { + } else if(arg == "--version") { printf("flatc version %s\n", FLATC_VERSION); exit(0); } else {