Skip to content

Commit 3a68d7d

Browse files
committed
CLI: add --version long argument to return PROJ version
1 parent 6d10acf commit 3a68d7d

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/apps/proj.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ int main(int argc, char **argv) {
496496
case 's': /* reverse output */
497497
reverseout = 1;
498498
continue;
499+
case '-': /* long option */
500+
if (std::strcmp(*argv, "--version") == 0) {
501+
(void)printf("%s\n", pj_get_version());
502+
exit(0);
503+
}
499504
default:
500505
emess(1, "invalid option: -%c", *arg);
501506
break;

src/proj_internal.h

+1
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ int pj_has_inverse(PJ *);
10041004

10051005
char *pj_strdup(const char *str);
10061006
const char PROJ_DLL *pj_get_release(void);
1007+
const char PROJ_DLL *pj_get_version(void);
10071008
void pj_acquire_lock(void);
10081009
void pj_release_lock(void);
10091010

src/release.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#define STR_HELPER(x) #x
77
#define STR(x) STR_HELPER(x)
88

9+
char const pj_version[] = STR(PROJ_VERSION_MAJOR) "." STR(
10+
PROJ_VERSION_MINOR) "." STR(PROJ_VERSION_PATCH);
11+
12+
const char *pj_get_version() { return pj_version; }
13+
914
char const pj_release[] = "Rel. " STR(PROJ_VERSION_MAJOR) "." STR(
1015
PROJ_VERSION_MINOR) "." STR(PROJ_VERSION_PATCH) ", "
1116
"September 1st, 2023";

0 commit comments

Comments
 (0)