Skip to content

Commit

Permalink
Merge pull request #11697 from rouault/argparse_80
Browse files Browse the repository at this point in the history
traditional CLI: limit argparse output width to 80; edit a few doc page to match that
  • Loading branch information
rouault authored Jan 20, 2025
2 parents fe25f91 + 84fa480 commit f2fc0d2
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 67 deletions.
3 changes: 2 additions & 1 deletion apps/argparse/argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,8 @@ class ArgumentParser {
}
}
cur_mutex = arg_mutex;
if (curline.size() + 1 + arg_inline_usage.size() >
if (curline.size() != indent_size &&
curline.size() + 1 + arg_inline_usage.size() >
this->m_usage_max_line_width) {
stream << curline << std::endl;
curline = std::string(indent_size, ' ');
Expand Down
2 changes: 1 addition & 1 deletion apps/gdalargumentparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ GDALArgumentParser::GDALArgumentParser(const std::string &program_name,
bool bForBinary)
: ArgumentParser(program_name, "", default_arguments::none)
{
set_usage_max_line_width(120);
set_usage_max_line_width(80);
set_usage_break_on_mutex();
add_usage_newline();

Expand Down
51 changes: 29 additions & 22 deletions doc/source/programs/gdal_translate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,36 @@ Synopsis

.. code-block::
gdal_translate [--help] [--long-usage] [--help-general]
[-ot Byte|Int8|[U]Int{16|32|64}|CInt{16|32}|[C]Float{32|64}]
[-if <format>]... [-of <output_format>] [--quiet]
[-b <band>]... [-mask <mask>] [-expand gray|rgb|rgba]
[[-strict]|[-not_strict]]
[-outsize <xsize[%]|0> <ysize[%]|0>] [-tr <xres> <yes>]
[-ovr <level>|AUTO|AUTO-<n>|NONE] [-sds]
[-r nearest,bilinear,cubic,cubicspline,lanczos,average,mode]
[[-scale [<src_min> <src_max> [<dst_min> <dst_max>]]]...|
[-scale_X [<src_min> <src_max> [<dst_min> <dst_max>]]]...|
[-unscale]]
[[-exponent <value>]|[-exponent_X <value>]...]
[-srcwin <xoff> <yoff> <xsize> <ysize>]
[-projwin <ulx> <uly> <lrx> <lry>]
[-projwin_srs <srs_def>] [-epo] [-eco] [-a_srs <srs_def>]
[-a_coord_epoch <epoch>] [-a_ullr <ulx> <uly> <lrx> <lry>]
[-a_nodata <value>|none]
[-a_gt <gt(0)> <gt(1)> <gt(2)> <gt(3)> <gt(4)> <gt(5)>]
[-a_scale <value>] [-a_offset <value>] [-nogcp]
[-gcp <pixel> <line> <easting> <northing> [<elevation>]]...
[-colorinterp {red|green|blue|alpha|gray|undefined|pan|
coastal|rededge|nir|swir|mwir|lwir|...},...]
[-colorinterp_X {red|green|blue|alpha|gray|undefined|pan|
coastal|rededge|nir|swir|mwir|lwir|...}]...
[[-stats]|[-approx_stats]]
[-norat] [-noxmp] [-co <NAME>=<VALUE>]...
[-mo <NAME>=<VALUE>]... [-dmo <DOMAIN>:<KEY>=<VALUE>]...
[-oo <NAME>=<VALUE>]...
<input_file> <output_file>
gdal_translate [--help] [--help-general] [--long-usage]
[-ot {Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int64/Float32/Float64/
CInt16/CInt32/CFloat32/CFloat64}] [-strict]
[-if <format>]... [-of <format>]
[-b <band>] [-mask <band>] [-expand {gray|rgb|rgba}]
[-outsize <xsize>[%]|0 <ysize>[%]|0] [-tr <xres> <yres>]
[-ovr <level>|AUTO|AUTO-<n>|NONE]
[-r {nearest,bilinear,cubic,cubicspline,lanczos,average,mode}]
[-unscale] [-scale[_bn] [<src_min> <src_max> [<dst_min> <dst_max>]]]... [-exponent[_bn] <exp_val>]...
[-srcwin <xoff> <yoff> <xsize> <ysize>] [-epo] [-eco]
[-projwin <ulx> <uly> <lrx> <lry>] [-projwin_srs <srs_def>]
[-a_srs <srs_def>] [-a_coord_epoch <epoch>]
[-a_ullr <ulx> <uly> <lrx> <lry>] [-a_nodata <value>]
[-a_gt <gt0> <gt1> <gt2> <gt3> <gt4> <gt5>]
[-a_scale <value>] [-a_offset <value>]
[-nogcp] [-gcp <pixel> <line> <easting> <northing> [<elevation>]]...
|-colorinterp{_bn} {red|green|blue|alpha|gray|undefined|pan|coastal|rededge|nir|swir|mwir|lwir|...}]
|-colorinterp {red|green|blue|alpha|gray|undefined|pan|coastal|rededge|nir|swir|mwir|lwir|...},...]
[-mo <META-TAG>=<VALUE>]... [-dmo "DOMAIN:META-TAG=VALUE"]... [-q] [-sds]
[-co <NAME>=<VALUE>]... [-stats] [-norat] [-noxmp]
[-oo <NAME>=<VALUE>]...
<src_dataset> <dst_dataset>
Description
-----------
Expand Down
3 changes: 2 additions & 1 deletion doc/source/programs/gdaladdo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Synopsis
.. code-block::
gdaladdo [--help] [--help-general]
[-r {nearest|average|rms|gauss|bilinear|cubic|cubicspline|lanczos|average_mp|average_magphase|mode}]
[-r {nearest|average|rms|gauss|bilinear|cubic|cubicspline|
lanczos|average_mp|average_magphase|mode}]
[-ro] [-clean] [-q] [-oo <NAME>=<VALUE>]... [-minsize <val>]
[--partial-refresh-from-source-timestamp]
[--partial-refresh-from-projwin <ulx> <uly> <lrx> <lry>]
Expand Down
34 changes: 17 additions & 17 deletions doc/source/programs/gdalbuildvrt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ Synopsis

.. code-block::
gdalbuildvrt [--help] [--help-general]
[-tileindex <field_name>]
[-resolution {highest|lowest|average|user}]
[-te <xmin> <ymin> <xmax> <ymax>] [-tr <xres> <yres>] [-tap]
[-separate] [-b <band>]... [-sd <n>]
[-allow_projection_difference] [-q]
[-addalpha] [-hidenodata]
[-srcnodata "<value>[ <value>]..."] [-vrtnodata "<value>[ <value>]..."
[-ignore_srcmaskband]
[-nodata_max_mask_threshold <threshold>]
[-a_srs <srs_def>]
[-r {nearest|bilinear|cubic|cubicspline|lanczos|average|mode}]
[-oo <NAME>=<VALUE>]...
[-co <NAME>=<VALUE>]...
[-input_file_list <filename>] [-overwrite]
[-strict | -non_strict]
<output_filename.vrt> <input_raster> [<input_raster>]...
gdalbuildvrt [--help] [--long-usage] [--help-general]
[--quiet]
[[-strict]|[-non_strict]]
[-tile_index <field_name>]
[-resolution user|average|highest|lowest] [-tr <xres> <yes>]
[-input_file_list <filename>] [-separate]
[-allow_projection_difference] [-sd <n>] [-tap]
[-te <xmin> <ymin> <xmax> <ymax>] [-addalpha] [-b <band>]...
[-hidenodata] [-overwrite]
[-srcnodata "<value>[ <value>]..."]
[-vrtnodata "<value>[ <value>]..."] [-a_srs <srs_def>]
[-r nearest|bilinear|cubic|cubicspline|lanczos|average|mode]
[-oo <NAME>=<VALUE>]... [-co <NAME>=<VALUE>]...
[-ignore_srcmaskband]
[-nodata_max_mask_threshold <threshold>]
<vrt_dataset_name> [<src_dataset_name>]...
Description
-----------
Expand Down
26 changes: 12 additions & 14 deletions doc/source/programs/gdalwarp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,31 @@ Synopsis
.. code-block::
gdalwarp [--help] [--long-usage] [--help-general]
[--quiet] [-overwrite] [-of <output_format>] [-co <NAME>=<VALUE>]...
[-s_srs <srs_def>] [-t_srs <srs_def>]
[--quiet] [-overwrite] [-of <output_format>]
[-co <NAME>=<VALUE>]... [-s_srs <srs_def>] [-t_srs <srs_def>]
[[-srcalpha]|[-nosrcalpha]]
[-dstalpha] [-tr <xres> <yres>|square] [-ts <width> <height>]
[-te <xmin> <ymin> <xmax> <ymax]
[-te_srs <srs_def>]
[-r near|bilinear|cubic|cubicspline|lanczos|average|rms|mode|min|max|med|q1|q3|sum]
[-te <xmin> <ymin> <xmax> <ymax>] [-te_srs <srs_def>]
[-r near|bilinear|cubic|cubicspline|lanczos|average|rms|mode|
min|max|med|q1|q3|sum]
[-ot Byte|Int8|[U]Int{16|32|64}|CInt{16|32}|[C]Float{32|64}]
<src_dataset_name>... <dst_dataset_name>
Advanced options:
[-wo <NAME>=<VALUE>]... [-multi]
[-s_coord_epoch <epoch>] [-t_coord_epoch <epoch>] [-ct <string>]
[-wo <NAME>=<VALUE>]... [-multi] [-s_coord_epoch <epoch>]
[-t_coord_epoch <epoch>] [-ct <string>]
[[-tps]|[-rpc]|[-geoloc]]
[-order <1|2|3>] [-refine_gcps <tolerance> [<minimum_gcps>]]
[-to <NAME>=<VALUE>]...
[-et <err_threshold>] [-wm <memory_in_mb>]
[-srcnodata "<value>[ <value>]..."]
[-to <NAME>=<VALUE>]... [-et <err_threshold>]
[-wm <memory_in_mb>] [-srcnodata "<value>[ <value>]..."]
[-dstnodata "<value>[ <value>]..."] [-tap]
[-wt Byte|Int8|[U]Int{16|32|64}|CInt{16|32}|[C]Float{32|64}]
[-cutline <datasource>|<WKT>] [-cutline_srs <srs_def>]
[-cwhere <expression>]
[[-cl <layername>]|[-csql <query>]]
[-cblend <distance>] [-crop_to_cutline]
[-nomd] [-cvmd <meta_conflict_value>] [-setci]
[-oo <NAME>=<VALUE>]... [-doo <NAME>=<VALUE>]...
[-ovr <level>|AUTO|AUTO-<n>|NONE]
[-cblend <distance>] [-crop_to_cutline] [-nomd]
[-cvmd <meta_conflict_value>] [-setci] [-oo <NAME>=<VALUE>]...
[-doo <NAME>=<VALUE>]... [-ovr <level>|AUTO|AUTO-<n>|NONE]
[[-vshift]|[-novshiftgrid]]
[-if <format>]... [-srcband <band>]... [-dstband <band>]...
Expand Down
24 changes: 13 additions & 11 deletions doc/source/programs/ogrinfo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ Synopsis

.. code-block::
ogrinfo [--help] [--help-general]
[-if <driver_name>] [-json] [-ro] [-q] [-where <restricted_where>|@<filename>]
[-spat <xmin> <ymin> <xmax> <ymax>] [-geomfield <field>] [-fid <fid>]
[-sql <statement>|@<filename>] [-dialect <sql_dialect>] [-al] [-rl]
[-so|-features] [-limit <nb_features>] [-fields={YES|NO}]]
[-geom={YES|NO|SUMMARY|WKT|ISO_WKT}] [-oo <NAME>=<VALUE>]...
[-nomd] [-listmdd] [-mdd <domain>|all]...
[-nocount] [-nogeomtype] [[-noextent] | [-extent3D]]
[-wkt_format WKT1|WKT2|<other_values>]
[-fielddomain <name>]
<datasource_name> [<layer> [<layer> ...]]
ogrinfo [--help] [--long-usage] [--help-general]
[-json] [-ro] [-update] [--quiet] [-fid <FID>]
[-spat <xmin> <ymin> <xmax> <ymax>] [-geomfield <field>]
[-where <restricted_where>]
[[-sql <statement|@filename>]|[-rl]]
[-dialect <dialect>] [-al]
[[-summary]|[-features]]
[-limit <nb_features>] [-fields YES|NO]
[-geom YES|NO|SUMMARY|WKT|ISO_WKT] [-oo <NAME=VALUE>]... [-nomd]
[-listmdd] [-mdd <domain>]... [-nocount] [-noextent] [-extent3D]
[-nogeomtype] [-wkt_format WKT1|WKT2|WKT2_2015|WKT2_2019]
[-fielddomain <name>] [-if <format>]...
filename [<layer_name>]...
Description
-----------
Expand Down

0 comments on commit f2fc0d2

Please sign in to comment.