Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdal CLI: add Bash completion #11563

Merged
merged 5 commits into from
Jan 6, 2025
Merged

gdal CLI: add Bash completion #11563

merged 5 commits into from
Jan 6, 2025

Conversation

rouault
Copy link
Member

@rouault rouault commented Jan 1, 2025

Fixes #11520

Examples:

$ gdal <TAB><TAB>
convert   info      pipeline  raster    vector
$ gdal r<TAB>
==>
$ gdal raster
$ gdal raster<TAB><TAB>
convert    edit       info       pipeline   reproject
$ gdal raster info -<TAB><TAB>
--approx-stats   -f               --help           --if             --json-usage     --min-max        --no-fl          --no-md          --oo             --stats
--checksum       --format         --hist           --input          --list-mdd       --mm             --no-gcp         --no-nodata      --open-option    --subdataset
--drivers        -h               -i               --input-format   --mdd            --no-ct          --no-mask        --of             --output-format  --version
$ gdal raster info --of <TAB><TAB>
json  text
$ gdal raster info --of=<TAB><TAB>
json  text
$ gdal raster info --of=j<TAB>
==>
$ gdal raster info --of=json
$ gdal raster convert --of <TAB><TAB>
AAIGrid          CALS             ERS              GSAG             ILWIS            KEA              MFF              OpenFileGDB      R                SQLite           WMTS
ADRG             COG              EXR              GSBG             ISCE             KMLSUPEROVERLAY  MFF2             PAux             Rasterlite       SRTMHGT          XPM
AVIF             CTable2          FIT              GTA              ISIS2            KRO              MRF              PCIDSK           RMF              Terragen         XYZ
BAG              DDS              FITS             GTiff            ISIS3            KTX2             netCDF           PCRaster         ROI_PAC          TileDB           Zarr
BASISU           DTED             GeoRaster        GTX              JP2ECW           LAN              NGW              PDF              RRASTER          USGSDEM          ZMap
BLX              ECW              GIF              HDF4Image        JP2KAK           LCP              NITF             PDS4             RST              VICAR
BMP              EHdr             GPKG             HEIF             JP2OpenJPEG      Leveller         NTv2             PNG              SAGA             VRT
BT               ELAS             GRIB             HF2              JPEG             MBTiles          NULL             PNM              SGI              WEBP
BYN              ENVI             GS7BG            HFA              JPEGXL           MEM              NWT_GRD          PostGISRaster    SIGDEM           WMS
$ gdal raster convert in.tif out.tif --co <TAB><TAB>
ALPHA=                           ENDIANNESS=                      JXL_EFFORT=                      PIXELTYPE=                       SOURCE_PRIMARIES_RED=            TIFFTAG_TRANSFERRANGE_BLACK=
BIGTIFF=                         GEOTIFF_KEYS_FLAVOR=             JXL_LOSSLESS=                    PREDICTOR=                       SOURCE_WHITEPOINT=               TIFFTAG_TRANSFERRANGE_WHITE=
BLOCKXSIZE=                      GEOTIFF_VERSION=                 LZMA_PRESET=                     PROFILE=                         SPARSE_OK=                       TILED=
[ ... snip ... ]
$ gdal raster convert in.tif out.tif --co COMP<TAB>
==>
$ gdal raster convert in.tif out.tif --co COMPRESS=
$ gdal raster convert in.tif out.tif --co COMPRESS=<TAB><TAB>
CCITTFAX3     CCITTRLE      JPEG          LERC          LERC_ZSTD     LZW           PACKBITS      ZSTD          
CCITTFAX4     DEFLATE       JXL           LERC_DEFLATE  LZMA          NONE          WEBP      
$ gdal raster convert in.tif out.tif --co TILED=<TAB><TAB>
NO   YES  
$ gdal raster convert in.tif out.tif --co ZLEVEL=<TAB><TAB>
1   10  11  12  2   3   4   5   6   7   8   9
$ gdal raster convert --of COG --co <TAB><TAB>
ADD_ALPHA=             EXTENT=                JXL_LOSSLESS=          NUM_THREADS=           OVERVIEW_RESAMPLING=   RESAMPLING=            WARP_RESAMPLING=       
ALIGNED_LEVELS=        GEOTIFF_VERSION=       LEVEL=                 OVERVIEW_COMPRESS=     OVERVIEWS=             SPARSE_OK=             ZOOM_LEVEL=            
BIGTIFF=               JXL_ALPHA_DISTANCE=    MAX_Z_ERROR=           OVERVIEW_COUNT=        PREDICTOR=             STATISTICS=            ZOOM_LEVEL_STRATEGY=   
BLOCKSIZE=             JXL_DISTANCE=          MAX_Z_ERROR_OVERVIEW=  OVERVIEW_PREDICTOR=    QUALITY=               TARGET_SRS=            
COMPRESS=              JXL_EFFORT=            NBITS=                 OVERVIEW_QUALITY=      RES=                   TILING_SCHEME=    
$ gdal --config <TAB><TAB>
... long list of known configuration options ...
$ gdal --config AWS_<TAB><TAB>
AWS_ACCESS_KEY_ID=                       AWS_DEFAULT_REGION=                      AWS_REQUEST_PAYER=                       AWS_STS_ENDPOINT=
AWS_CONFIG_FILE=                         AWS_HTTPS=                               AWS_ROLE_ARN=                            AWS_STS_REGION=
AWS_CONTAINER_AUTHORIZATION_TOKEN=       AWS_MAX_KEYS=                            AWS_ROLE_SESSION_NAME=                   AWS_STS_REGIONAL_ENDPOINTS=
AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE=  AWS_NO_SIGN_REQUEST=                     AWS_S3_ENDPOINT=                         AWS_TIMESTAMP=
AWS_CONTAINER_CREDENTIALS_FULL_URI=      AWS_PROFILE=                             AWS_SECRET_ACCESS_KEY=                   AWS_VIRTUAL_HOSTING=
AWS_DEFAULT_PROFILE=                     AWS_REGION=                              AWS_SESSION_TOKEN=                       AWS_WEB_IDENTITY_TOKEN_FILE=
$ gdal raster reproject --dst-crs 
EPSG:      ESRI:      IAU_2015:  IGNF:      NKG:       OGC:      
$ gdal raster reproject --dst-crs EP<TAB>
==>
$ gdal raster reproject --dst-crs EPSG:
$ gdal raster reproject --dst-crs EPSG:<TAB>
10150 -- MSL UK & Ireland VORF08 depth
10151 -- CD UK & Ireland VORF08 depth
10156 -- ETRS89 + MSL UK & Ireland VORF08 depth
10157 -- ETRS89 + CD UK & Ireland VORF08 depth
[ ... snip ... ]
$ gdal raster reproject --dst-crs EPSG:432<TAB>
4322 -- WGS 72                  4324 -- WGS 72BE                4326 -- WGS 84                  4327 -- WGS 84 (geographic 3D)  4328 -- WGS 84 (geocentric)     4329 -- WGS 84 (3D)

Last but not least: autocompletion of VSI files

$ gdal raster info /vsis3/my_bucket/b<TAB><TAB>
/vsis3/my_bucket/byte.tif      /vsis3/my_bucket/byte2.tif

@rouault rouault added this to the 3.11.0 milestone Jan 1, 2025
@rouault rouault added the funded through GSP Work funded through the GDAL Sponsorship Program label Jan 1, 2025
@rouault rouault force-pushed the gdal_completion branch 2 times, most recently from 5ea32a4 to 651abe7 Compare January 1, 2025 18:12
@rouault rouault force-pushed the gdal_completion branch 2 times, most recently from ff0c031 to 821f294 Compare January 1, 2025 18:21
@OSGeo OSGeo deleted a comment from coveralls Jan 1, 2025
@rouault rouault force-pushed the gdal_completion branch 2 times, most recently from 6654eea to 12d1899 Compare January 1, 2025 18:45
@rouault rouault force-pushed the gdal_completion branch 3 times, most recently from d2346af to e25a4ab Compare January 1, 2025 22:46
@rouault rouault force-pushed the gdal_completion branch 2 times, most recently from c9493ff to a3b32dc Compare January 1, 2025 23:18
@rouault rouault force-pushed the gdal_completion branch 10 times, most recently from 36553dd to e53e8ab Compare January 2, 2025 04:10
@rouault rouault force-pushed the gdal_completion branch 8 times, most recently from 875906a to de2b68d Compare January 2, 2025 14:24
Examples:
```
$ gdal <TAB><TAB>
convert   info      pipeline  raster    vector
```

```
$ gdal r<TAB>
==>
$ gdal raster
```

```
$ gdal raster<TAB><TAB>
convert    edit       info       pipeline   reproject
```

```
$ gdal raster info -<TAB><TAB>
--approx-stats   -f               --help           --if             --json-usage     --min-max        --no-fl          --no-md          --oo             --stats
--checksum       --format         --hist           --input          --list-mdd       --mm             --no-gcp         --no-nodata      --open-option    --subdataset
--drivers        -h               -i               --input-format   --mdd            --no-ct          --no-mask        --of             --output-format  --version
```

```
$ gdal raster info --of <TAB><TAB>
json  text
```

```
$ gdal raster info --of=<TAB><TAB>
json  text
```

```
$ gdal raster info --of=j<TAB>
==>
$ gdal raster info --of=json
```

```
$ gdal raster convert --of <TAB><TAB>
AAIGrid          CALS             ERS              GSAG             ILWIS            KEA              MFF              OpenFileGDB      R                SQLite           WMTS
ADRG             COG              EXR              GSBG             ISCE             KMLSUPEROVERLAY  MFF2             PAux             Rasterlite       SRTMHGT          XPM
AVIF             CTable2          FIT              GTA              ISIS2            KRO              MRF              PCIDSK           RMF              Terragen         XYZ
BAG              DDS              FITS             GTiff            ISIS3            KTX2             netCDF           PCRaster         ROI_PAC          TileDB           Zarr
BASISU           DTED             GeoRaster        GTX              JP2ECW           LAN              NGW              PDF              RRASTER          USGSDEM          ZMap
BLX              ECW              GIF              HDF4Image        JP2KAK           LCP              NITF             PDS4             RST              VICAR
BMP              EHdr             GPKG             HEIF             JP2OpenJPEG      Leveller         NTv2             PNG              SAGA             VRT
BT               ELAS             GRIB             HF2              JPEG             MBTiles          NULL             PNM              SGI              WEBP
BYN              ENVI             GS7BG            HFA              JPEGXL           MEM              NWT_GRD          PostGISRaster    SIGDEM           WMS
```

```
$ gdal raster convert in.tif out.tif --co <TAB><TAB>
ALPHA=                           ENDIANNESS=                      JXL_EFFORT=                      PIXELTYPE=                       SOURCE_PRIMARIES_RED=            TIFFTAG_TRANSFERRANGE_BLACK=
BIGTIFF=                         GEOTIFF_KEYS_FLAVOR=             JXL_LOSSLESS=                    PREDICTOR=                       SOURCE_WHITEPOINT=               TIFFTAG_TRANSFERRANGE_WHITE=
BLOCKXSIZE=                      GEOTIFF_VERSION=                 LZMA_PRESET=                     PROFILE=                         SPARSE_OK=                       TILED=
[ ... snip ... ]
```

```
$ gdal raster convert in.tif out.tif --co COMP<TAB>
==>
$ gdal raster convert in.tif out.tif --co COMPRESS=
```

```
$ gdal raster convert in.tif out.tif --co COMPRESS=<TAB><TAB>
CCITTFAX3     CCITTRLE      JPEG          LERC          LERC_ZSTD     LZW           PACKBITS      ZSTD
CCITTFAX4     DEFLATE       JXL           LERC_DEFLATE  LZMA          NONE          WEBP
```

```
$ gdal raster convert in.tif out.tif --co TILED=<TAB><TAB>
NO   YES
```

```
$ gdal raster convert in.tif out.tif --co ZLEVEL=<TAB><TAB>
1   10  11  12  2   3   4   5   6   7   8   9
```

```
$ gdal raster convert --of COG --co <TAB><TAB>
ADD_ALPHA=             EXTENT=                JXL_LOSSLESS=          NUM_THREADS=           OVERVIEW_RESAMPLING=   RESAMPLING=            WARP_RESAMPLING=
ALIGNED_LEVELS=        GEOTIFF_VERSION=       LEVEL=                 OVERVIEW_COMPRESS=     OVERVIEWS=             SPARSE_OK=             ZOOM_LEVEL=
BIGTIFF=               JXL_ALPHA_DISTANCE=    MAX_Z_ERROR=           OVERVIEW_COUNT=        PREDICTOR=             STATISTICS=            ZOOM_LEVEL_STRATEGY=
BLOCKSIZE=             JXL_DISTANCE=          MAX_Z_ERROR_OVERVIEW=  OVERVIEW_PREDICTOR=    QUALITY=               TARGET_SRS=
COMPRESS=              JXL_EFFORT=            NBITS=                 OVERVIEW_QUALITY=      RES=                   TILING_SCHEME=
```

```
$ gdal --config <TAB><TAB>
... long list of known configuration options ...
```

```
$ gdal --config AWS_<TAB><TAB>
AWS_ACCESS_KEY_ID=                       AWS_DEFAULT_REGION=                      AWS_REQUEST_PAYER=                       AWS_STS_ENDPOINT=
AWS_CONFIG_FILE=                         AWS_HTTPS=                               AWS_ROLE_ARN=                            AWS_STS_REGION=
AWS_CONTAINER_AUTHORIZATION_TOKEN=       AWS_MAX_KEYS=                            AWS_ROLE_SESSION_NAME=                   AWS_STS_REGIONAL_ENDPOINTS=
AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE=  AWS_NO_SIGN_REQUEST=                     AWS_S3_ENDPOINT=                         AWS_TIMESTAMP=
AWS_CONTAINER_CREDENTIALS_FULL_URI=      AWS_PROFILE=                             AWS_SECRET_ACCESS_KEY=                   AWS_VIRTUAL_HOSTING=
AWS_DEFAULT_PROFILE=                     AWS_REGION=                              AWS_SESSION_TOKEN=                       AWS_WEB_IDENTITY_TOKEN_FILE=
```

```
$ gdal raster reproject --dst-crs
EPSG:      ESRI:      IAU_2015:  IGNF:      NKG:       OGC:
```

```
$ gdal raster reproject --dst-crs EP<TAB>
==>
$ gdal raster reproject --dst-crs EPSG:
```

```
$ gdal raster reproject --dst-crs EPSG:<TAB>
10150 -- MSL UK & Ireland VORF08 depth
10151 -- CD UK & Ireland VORF08 depth
10156 -- ETRS89 + MSL UK & Ireland VORF08 depth
10157 -- ETRS89 + CD UK & Ireland VORF08 depth
[ ... snip ... ]
```

```
$ gdal raster reproject --dst-crs EPSG:432<TAB>
4322 -- WGS 72                  4324 -- WGS 72BE                4326 -- WGS 84                  4327 -- WGS 84 (geographic 3D)  4328 -- WGS 84 (geocentric)     4329 -- WGS 84 (3D)
```

Last but not least: autocompletion of VSI files
```
$ gdal raster info /vsis3/my_bucket/b<TAB><TAB>
/vsis3/my_bucket/byte.tif      /vsis3/my_bucket/byte2.tif
```
@rouault rouault merged commit 65c35b5 into OSGeo:master Jan 6, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
funded through GSP Work funded through the GDAL Sponsorship Program
Projects
None yet
Development

Successfully merging this pull request may close these issues.

completion sub-command for the new gdal cli
1 participant