From 3a68d7d5b3246661cad927bf7f7b11e65fa57ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Thu, 20 Jul 2023 10:34:46 +0200 Subject: [PATCH] CLI: add --version long argument to return PROJ version --- src/apps/proj.cpp | 5 +++++ src/proj_internal.h | 1 + src/release.cpp | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp index d5afaa4909..6a149d9135 100644 --- a/src/apps/proj.cpp +++ b/src/apps/proj.cpp @@ -496,6 +496,11 @@ int main(int argc, char **argv) { case 's': /* reverse output */ reverseout = 1; continue; + case '-': /* long option */ + if (std::strcmp(*argv, "--version") == 0) { + (void)printf("%s\n", pj_get_version()); + exit(0); + } default: emess(1, "invalid option: -%c", *arg); break; diff --git a/src/proj_internal.h b/src/proj_internal.h index 55abb8c115..f303a75f9a 100644 --- a/src/proj_internal.h +++ b/src/proj_internal.h @@ -1004,6 +1004,7 @@ int pj_has_inverse(PJ *); char *pj_strdup(const char *str); const char PROJ_DLL *pj_get_release(void); +const char PROJ_DLL *pj_get_version(void); void pj_acquire_lock(void); void pj_release_lock(void); diff --git a/src/release.cpp b/src/release.cpp index 5742f3b6a3..db28ecfbe9 100644 --- a/src/release.cpp +++ b/src/release.cpp @@ -6,6 +6,11 @@ #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) +char const pj_version[] = STR(PROJ_VERSION_MAJOR) "." STR( + PROJ_VERSION_MINOR) "." STR(PROJ_VERSION_PATCH); + +const char *pj_get_version() { return pj_version; } + char const pj_release[] = "Rel. " STR(PROJ_VERSION_MAJOR) "." STR( PROJ_VERSION_MINOR) "." STR(PROJ_VERSION_PATCH) ", " "September 1st, 2023";