Skip to content

Commit

Permalink
CLI: add --version long argument to return PROJ version
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti committed Jul 20, 2023
1 parent 6d10acf commit 3a68d7d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/apps/proj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/proj_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions src/release.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 3a68d7d

Please sign in to comment.