Skip to content

Commit

Permalink
Add longoptions support for gmtinfo. (#7996)
Browse files Browse the repository at this point in the history
* Add longoptions support for gmtinfo.

* Update gmtinfo_inc.h

* Hide deprecated -S option

Still works but now longer listed in usage, synopsis, or documentation.

* Update gmtinfo_inc.h

---------

Co-authored-by: Paul Wessel <pwessel@hawaii.edu>
  • Loading branch information
rbdavis and PaulWessel authored Nov 15, 2023
1 parent 274eb0d commit a155451
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 43 deletions.
12 changes: 0 additions & 12 deletions doc/rst/source/gmtinfo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Synopsis
[ |-F|\ [**i**\|\ **d**\|\ **t**] ]
[ |-I|\ [**b**\|\ **e**\|\ **f**\|\ **p**\|\ **s**]\ *dx*\ [/*dy*\ [/*dz*...][**+e**\|\ **r**\|\ **R**\ *incs*] ]
[ |-L| ]
[ |-S|\ [**x**][**y**] ]
[ |-T|\ *dz*\ [**w**\|\ **d**\|\ **h**\|\ **m**\|\ **s**][**+c**\ *col*] ]
[ |SYN_OPT-V| ]
[ |SYN_OPT-a| ]
Expand Down Expand Up @@ -144,17 +143,6 @@ Optional Arguments
If used with |-I| it will round inwards so that the resulting bounds
lie within the actual data domain.

.. _-S:

**-S**\ [**x**][**y**]
Add extra space for error bars. Useful together with |-I| option
and when later plotting with :doc:`plot` **-E**. |-S|\ **x** leaves space
for horizontal error bars using the values in third
(2) column. |-S|\ **y** leaves space for vertical error
bars using the values in fourth (3) column. |-S|
or |-S|\ **xy** leaves space for both error bars using the values in
third and fourth (2 and 3) columns.

.. _-T:

**-T**\ *dz*\ [**w**\|\ **d**\|\ **h**\|\ **m**\|\ **s**][**+c**\ *col*]
Expand Down
11 changes: 3 additions & 8 deletions src/gmtinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct GMTINFO_CTRL { /* All control options for this program (except common arg
struct GMTINFO_L { /* -L */
bool active;
} L;
struct GMTINFO_S { /* -S[x|y] */
struct GMTINFO_S { /* -S[x|y] [Deprecated in 6.5] */
bool active;
bool xbar, ybar;
} S;
Expand Down Expand Up @@ -128,7 +128,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE);
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
GMT_Usage (API, 0, "usage: %s [<table>] [-Aa|t|s] [-C] [-D[<dx>[/<dy>]]] [-EL|l|H|h[<col>]] "
"[-Fi|d|t] [-I[b|e|f|p|s]<dx>[/<dy>[/<dz>..]][+e|r|R<incs>]] [-L] [-S[x][y]] [-T<dz>[%s][+c<col>]] "
"[-Fi|d|t] [-I[b|e|f|p|s]<dx>[/<dy>[/<dz>..]][+e|r|R<incs>]] [-L] [-T<dz>[%s][+c<col>]] "
"[%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s]",
name, GMT_TIME_FIX_UNITS_DISPLAY, GMT_V_OPT, GMT_a_OPT, GMT_bi_OPT, GMT_d_OPT, GMT_e_OPT, GMT_f_OPT, GMT_g_OPT, GMT_h_OPT,
GMT_i_OPT, GMT_o_OPT, GMT_qi_OPT, GMT_r_OPT, GMT_s_OPT, GMT_w_OPT, GMT_colon_OPT, GMT_PAR_OPT);
Expand Down Expand Up @@ -169,11 +169,6 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
"or use +e which is like +r but makes sure the region extends at least by %g x <inc>.\n", GMT_REGION_INCFACTOR);
GMT_Usage (API, 1, "\n-L Determine limiting region. With -I it rounds inward so bounds are within data range. "
"Use -A to find the limiting common bounds of all segments or tables.");
GMT_Usage (API, 1, "\n-S[x][y]");
GMT_Usage (API, -2, "Add extra space for error bars. Useful together with -I.");
GMT_Usage (API, 3, "-Sx: Leaves space for horizontal error bar using value in third (2) column.");
GMT_Usage (API, 3, "-Sy: Leaves space for vertical error bar using value in third (2) column.");
GMT_Usage (API, 3, "-S or -Sxy: Leaves space for both error bars using values in third&fourth (2&3) columns.");
GMT_Usage (API, 1, "\n-T<dz>[%s][+c<col>]", GMT_TIME_FIX_UNITS_DISPLAY);
GMT_Usage (API, -2, "Return textstring -Tzmin/zmax/dz to nearest multiple of the given <dz>.");
GMT_Usage (API, -2, "Note: Calculations are based on the first (0) column; append +c<col> to use another column. "
Expand Down Expand Up @@ -325,7 +320,7 @@ static int parse (struct GMT_CTRL *GMT, struct GMTINFO_CTRL *Ctrl, struct GMT_OP
n_errors += gmt_M_repeated_module_option (API, Ctrl->L.active);
n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0);
break;
case 'S': /* Error bar output */
case 'S': /* Error bar output [deprecated in 6.5] */
n_errors += gmt_M_repeated_module_option (API, Ctrl->S.active);
j = 0;
while (opt->arg[j]) {
Expand Down
37 changes: 14 additions & 23 deletions src/longopt/gmtinfo_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,24 @@ static struct GMT_KEYWORD_DICTIONARY module_kw[] = {
/* separator, short_option, long_option,
short_directives, long_directives,
short_modifiers, long_modifiers */
{ 0, 'A', "",
"", "",
"", "" },
{ 0, 'C', "",
"", "",
"", "" },
{ 0, 'D', "",
"", "",
"", "" },
{ 0, 'E', "",
"", "",
{ 0, 'A', "report",
"a,t,s", "all,per_table,per_segment",
"", "" },
{ 0, 'F', "",
"", "",
"", "" },
{ 0, 'I', "",
"", "",
{ 0, 'C', "columns|numeric", "", "", "", "" },
{ 0, 'D', "center", "", "", "", "" },
{ 0, 'E', "get_record",
"l,L,h,H", "min,minabs,max,maxabs",
"", "" },
{ 0, 'L', "",
"", "",
{ 0, 'F', "counts",
"i,d,t", "totals,segments,segments_reset",
"", "" },
{ 0, 'S', "",
{ 0, 'I', "inc|increment|spacing",
"b,e,f,p,s", "box,exact,fft,override,surface",
"e,r,R", "extend_box,adjust,extend_region" },
{ 0, 'L', "common_limits", "", "", "", "" },
{ 0, 'T', "nearest_multiple",
"", "",
"", "" },
{ 0, 'T', "",
"", "",
"", "" },
"c", "column" },
{ 0, '\0', "", "", "", "", ""} /* End of list marked with empty option and strings */
};
#endif /* !GMTINFO_INC_H */

0 comments on commit a155451

Please sign in to comment.