@@ -119,16 +119,17 @@ def dummy_context(arg):
119119 yield arg
120120
121121
122- def build_arg_string (kwdict , infile = None , outfile = None ):
122+ def build_arg_string (kwdict , confdict = None , infile = None , outfile = None ):
123123 r"""
124- Convert a dict and optional input/output files into a GMT argument string.
124+ Convert keyword dictionaries and input/output files into a GMT argument
125+ string.
125126
126127 Make sure all values in ``kwdict`` have been previously converted to a
127128 string representation using the ``kwargs_to_strings`` decorator. The only
128129 exceptions are True, False and None.
129130
130131 Any lists or tuples left will be interpreted as multiple entries for the
131- same command line argument . For example, the kwargs entry ``'B': ['xa',
132+ same command line option . For example, the kwargs entry ``'B': ['xa',
132133 'yaf']`` will be converted to ``-Bxa -Byaf`` in the argument string.
133134
134135 Note that spaces `` `` in arguments are converted to the equivalent octal
@@ -139,7 +140,9 @@ def build_arg_string(kwdict, infile=None, outfile=None):
139140 Parameters
140141 ----------
141142 kwdict : dict
142- A dict containing parsed keyword arguments.
143+ A dictionary containing parsed keyword arguments.
144+ confdict : dict
145+ A dictionary containing configurable GMT parameters.
143146 infile : str or pathlib.Path
144147 The input file.
145148 outfile : str or pathlib.Path
@@ -149,8 +152,10 @@ def build_arg_string(kwdict, infile=None, outfile=None):
149152 -------
150153 args : str
151154 The space-delimited argument string with '-' inserted before each
152- keyword. The arguments are sorted alphabetically, with optional input
153- file at the beginning and optional output file at the end.
155+ keyword, or '--' inserted before GMT configuration key-value pairs.
156+ The keyword arguments are sorted alphabetically, followed by GMT
157+ configuration key-value pairs, with optional input file at the
158+ beginning and optional output file at the end.
154159
155160 Examples
156161 --------
@@ -199,11 +204,12 @@ def build_arg_string(kwdict, infile=None, outfile=None):
199204 >>> print(
200205 ... build_arg_string(
201206 ... dict(A="0", B=True, C="rainbow"),
207+ ... confdict=dict(FORMAT_DATE_MAP="o dd"),
202208 ... infile="input.txt",
203209 ... outfile="output.txt",
204210 ... )
205211 ... )
206- input.txt -A0 -B -Crainbow ->output.txt
212+ input.txt -A0 -B -Crainbow --FORMAT_DATE_MAP="o dd" - >output.txt
207213 """
208214 gmt_args = []
209215
@@ -227,6 +233,10 @@ def build_arg_string(kwdict, infile=None, outfile=None):
227233 _value = str (kwdict [key ]).replace (" " , "" )
228234 gmt_args .append (rf"-{ key } { _value } " )
229235 gmt_args = sorted (gmt_args )
236+
237+ if confdict :
238+ gmt_args .extend (f'--{ key } ="{ value } "' for key , value in confdict .items ())
239+
230240 if infile :
231241 gmt_args = [str (infile )] + gmt_args
232242 if outfile :
0 commit comments