gdal icon indicating copy to clipboard operation
gdal copied to clipboard

Trim gdal_calc extra large usage message

Open jidanni opened this issue 1 year ago • 0 comments

Feature description

$ gdal_calc
usage: gdal_calc [--help] [--help-general] --calc [expression ...]
                 [-a [filename ...]] [--a_band [n ...]] [-b [filename ...]]
                 [--b_band [n ...]] [-c [filename ...]] [--c_band [n ...]]

                 ...

                 [--U_band [n ...]] [-V [filename ...]] [--V_band [n ...]]
                 [-W [filename ...]] [--W_band [n ...]] [-X [filename ...]]
                 [--X_band [n ...]] [-Y [filename ...]] [--Y_band [n ...]]
                 [-Z [filename ...]] [--Z_band [n ...]] --outfile filename
                 [--NoDataValue value] [--hideNoData] [--type datatype]
                 [--format gdal_format] [--creation-option option]
                 [--allBands [a-z, A-Z]] [--overwrite] [--debug] [--quiet]
                 [--color-table COLOR_TABLE]
                 [--extent {ignore,fail,union,intersect} | --projwin ulx uly lrx lry]
                 [--projectionCheck]
gdal_calc: error: the following arguments are required: --calc, --outfile

First problem: using three columns to show a two column table, gives

LMM NNO OPP QQR

Two columns are more sensible,

MM NN OO

i.e.,

 [-L [filename ...]] [--L_band [n ...]]
 [-M [filename ...]] [--M_band [n ...]]
 [-N [filename ...]] [--N_band [n ...]]

Or even four columns are OK,

MMNN OOPP QQRR

if they don't go off the margin.

Second problem: showing all ( 26 + 26 ) * 2 overloads the user, reducing clarity. Maybe just show the first and last with some dots in the middle. In fact as I have done above.

Or, 10 times better would be just use the usage message one gets with gdal_calc --help:

$ gdal_calc --help
usage: gdal_calc [--help] [--help-general] --calc [expression ...]
                 [-A [filename ...]] [--A_band [n ...]] --outfile filename
                 [--NoDataValue value] [--hideNoData] [--type datatype]
                 [--format gdal_format] [--creation-option option]
                 [--allBands [a-z, A-Z]] [--overwrite] [--debug] [--quiet]
                 [--color-table COLOR_TABLE]
                 [--extent {ignore,fail,union,intersect} | --projwin ulx uly lrx lry]
                 [--projectionCheck]

I.e., the error usage message and --help usage message should be the same. Version 3.9.

jidanni avatar May 29 '24 11:05 jidanni