Skip to content

Commit

Permalink
Let gmtdefaults -D follow what man page says (#7682)
Browse files Browse the repository at this point in the history
* Let gmtdefaults -D follow what man page says

Says argument to -D is optional and the default internally is then SI.  This PR fixes the code to let -D basically mean -Ds.  Man page updated to remove babble of compile time setting.

* Update gmtdefaults.c

* Update gmtdefaults.c
  • Loading branch information
PaulWessel authored Aug 23, 2023
1 parent f272ae6 commit f662704
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions doc/rst/source/gmtdefaults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Description
There are three ways to change some of the settings: (1) use the command
:doc:`gmtset`, (2) use any text editor to edit the file :doc:`gmt.conf` in your
home, ~/.gmt or current directory (if you do not have this file, run
:doc:`gmtdefaults` |-D| > gmt.conf to get one with the system default
:doc:`gmtdefaults` |-D| > gmt.conf to get one with the system SI default
settings), or (3) override any parameter by specifying one or more
**-**\ **-PARAMETER**\ =\ *VALUE* statements on the command line of any GMT
command (**PARAMETER** and *VALUE* are any combination in :doc:`gmt.conf`). In
Expand All @@ -49,7 +49,7 @@ Optional Arguments
**-D**\ [**u**\|\ **s**]
Print the system GMT defaults settings to standard output. Append **u**
for US defaults or **s** for SI defaults. [|-D| alone gives the
version selected at compile time; If |-D| is omitted, the user's
SI defaults; If |-D| is omitted, the user's
currently active defaults are printed.]

.. include:: explain_help.rst_
Expand All @@ -70,7 +70,7 @@ are user-definable in GMT.
Examples
--------

To get a copy of the GMT parameter defaults in your home directory, run::
To get a copy of the GMT parameter SI defaults in your home directory, run::

gmt defaults -D > ~/gmt.conf

Expand Down
10 changes: 8 additions & 2 deletions src/gmtdefaults.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
GMT_Message (API, GMT_TIME_NONE, " OPTIONAL ARGUMENTS:\n");
GMT_Usage (API, 1, "\n-D[s|u]");
GMT_Usage (API, -2, "Print the current GMT default settings. Optionally append a directive:");
GMT_Usage (API, 3, "s: Print the SI version of the system defaults.");
GMT_Usage (API, 3, "s: Print the SI version of the system defaults [Default].");
GMT_Usage (API, 3, "u: Print the US version of the system defaults.");
GMT_Usage (API, -2, "Note: ALL settings will be written to standard output.");
GMT_Option (API, "V");
Expand Down Expand Up @@ -96,7 +96,13 @@ static int parse (struct GMT_CTRL *GMT, struct GMTDEFAULTS_CTRL *Ctrl, struct GM

case 'D': /* Get GMT system-wide defaults settings */
n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active);
n_errors += gmt_get_required_char (GMT, opt->arg, opt->option, 0, &Ctrl->D.mode);
if (opt->arg[0]) { /* Specified an argument */
n_errors += gmt_get_required_char (GMT, opt->arg, opt->option, 0, &Ctrl->D.mode);
if (strchr ("su", Ctrl->D.mode) == NULL) {
GMT_Report (API, GMT_MSG_ERROR, "Option -D: Argument %s is not recognized.\n", opt->arg);
n_errors++;
}
}
break;
case 'L': /* List the user's current GMT defaults settings */
if (gmt_M_compat_check (GMT, 4)) {
Expand Down

0 comments on commit f662704

Please sign in to comment.