MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / gmt_report_usage

Function gmt_report_usage

src/gmt_init.c:20630–20662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20628}
20629
20630int gmt_report_usage (struct GMTAPI_CTRL *API, struct GMT_OPTION *options, unsigned int special, int (*usage)(struct GMTAPI_CTRL *, int)) {
20631 /* Handle the way classic and modern mode modules report their usage messages.
20632 * Set special == 1 if the classic module can be run with no options at all and still be expected to do things (e.g., silently read stdin) */
20633 int code = GMT_NOERROR; /* Default is no usage message was requested and we move on to parsing the arguments */
20634 if (API->GMT->current.setting.run_mode == GMT_MODERN) { /* Under modern mode we always require an option like -? or -^ to call usage */
20635 if (options) { /* Modern mode will only print the usage if one of the usage-options are given (but see exception for one-liners) */
20636 if (options->option == GMT_OPT_USAGE) /* -? Return the usage message */
20637 code = GMT_OPT_USAGE;
20638 else if (options->option == GMT_OPT_SYNOPSIS) /* -^ or - Return the synopsis message */
20639 code = GMT_SYNOPSIS;
20640 else if (options->option == '+' && !options->arg[0]) /* -+ Return the extended synopsis message */
20641 code = GMT_OPT_USAGE, API->GMT->common.synopsis.extended = true;
20642 }
20643 else if (API->usage) /* One-liner modern mode with no args must give usage */
20644 code = GMT_OPT_USAGE;
20645 }
20646 else if (special) { /* Some classic modules require an option to show usage, otherwise expect input (e.g., gmtinfo) */
20647 if (options && options->option == GMT_OPT_USAGE)
20648 code = GMT_OPT_USAGE;
20649 if (options && options->option == GMT_OPT_SYNOPSIS)
20650 code = GMT_SYNOPSIS;
20651 }
20652 else { /* Regular classic module behavior */
20653 if (!options || options->option == GMT_OPT_USAGE)
20654 code = GMT_OPT_USAGE;
20655 else if (options->option == GMT_OPT_SYNOPSIS)
20656 code = GMT_SYNOPSIS;
20657 }
20658
20659 if (code) /* Must call the usage function */
20660 usage (API, code);
20661 return (code);
20662}
20663
20664GMT_LOCAL void gmtinit_reparse_io_option (struct GMT_CTRL *GMT, uint64_t n_columns, unsigned int dir) {
20665 char text[GMT_LEN8] = {""}, token[PATH_MAX] = {""}, *stropt[2] = {"i", "o"}, chropt[2] = {'i', 'o'};

Callers 15

GMT_grd2cptFunction · 0.85
GMT_gmtconvertFunction · 0.85
GMT_grdvolumeFunction · 0.85
GMT_docsFunction · 0.85
GMT_nearneighborFunction · 0.85
GMT_pswiggleFunction · 0.85
GMT_pssolarFunction · 0.85
GMT_grdconvertFunction · 0.85
GMT_grdviewFunction · 0.85
GMT_gmtsetFunction · 0.85
GMT_grdgradientFunction · 0.85
GMT_grdeditFunction · 0.85

Calls 1

usageFunction · 0.70

Tested by 1

GMT_spectrum1dFunction · 0.68