As we try to avoid having any code that calls exit, I find this code in gmtinit_parse_dash_option:
/*! parse any --PARAM[=value] arguments */
GMT_LOCAL int gmtinit_parse_dash_option (struct GMT_CTRL *GMT, char *text) {
int n;
char *this_c = NULL, message[GMT_LEN128] = {""};
if (!text)
return (GMT_NOERROR);
/* print version and exit */
if (strcmp (text, "version") == 0) {
snprintf (message, GMT_LEN128, "%s\n", GMT_PACKAGE_VERSION_WITH_GIT_REVISION);
GMT->parent->print_func (stdout, message);
/* cannot call gmt_M_free_options() from here, so we are leaking on exit.
* struct GMTAPI_CTRL *G = GMT->parent;
* if (GMT_Destroy_Session (G))
* GMT_exit (GMT, GMT_PARSE_ERROR); */
GMT_exit (GMT, GMT_NOERROR);
}
/* print GMT folders and exit */
if (strcmp (text, "show-datadir") == 0) {
snprintf (message, GMT_LEN128, "%s\n", GMT->session.SHAREDIR);
GMT->parent->print_func (stdout, message);
/* leaking on exit same as above. */
GMT_exit (GMT, GMT_NOERROR);
}
Since the gmt driver processes --version and --show-data-dir, I assume these were placed here for use from external environments like python and Julia (please remind me if you remember, @joa-quim and @seisman ). We have other ways to get the version from the API - not sure about the datadir.
As we try to avoid having any code that calls exit, I find this code in gmtinit_parse_dash_option:
Since the gmt driver processes --version and --show-data-dir, I assume these were placed here for use from external environments like python and Julia (please remind me if you remember, @joa-quim and @seisman ). We have other ways to get the version from the API - not sure about the datadir.