forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgdal-bash-completion.sh
288 lines (284 loc) · 9.45 KB
/
gdal-bash-completion.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# shellcheck shell=bash disable=SC2148
# File auto-generated by completionFinder.py, do not modify manually
function_exists() {
declare -f -F "$1" > /dev/null
return $?
}
# Checks that bash-completion is recent enough
function_exists _get_comp_words_by_ref || return 0
_gdal()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
choices=$(gdal completion ${COMP_LINE})
if [[ "$cur" == "=" ]]; then
mapfile -t COMPREPLY < <(compgen -W "$choices" --)
elif [[ "$cur" == ":" ]]; then
mapfile -t COMPREPLY < <(compgen -W "$choices" --)
elif [[ "$cur" == "!" ]]; then
mapfile -t COMPREPLY < <(compgen -W "$choices" -P "! " --)
else
mapfile -t COMPREPLY < <(compgen -W "$choices" -- "$cur")
fi
for element in "${COMPREPLY[@]}"; do
if [[ $element == */ ]]; then
# Do not add a space if one of the suggestion ends with slash
compopt -o nospace
break
elif [[ $element == *= ]]; then
# Do not add a space if one of the suggestion ends with equal
compopt -o nospace
break
elif [[ $element == *: ]]; then
# Do not add a space if one of the suggestion ends with colon
compopt -o nospace
break
fi
done
}
complete -o default -F _gdal gdal
_gdal2tiles.py()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list=""
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
return 0
}
complete -o default -F _gdal2tiles.py gdal2tiles.py
_gdal2xyz.py()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list="--help --help-general -skip -srcwin -b -allbands -csv -skipnodata -srcnodata -dstnodata --version --build --license --formats --format --optfile --config --debug --pause --locale "
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
tool=${COMP_WORDS[0]}
case "$prev" in
--format)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
esac
return 0
}
complete -o default -F _gdal2xyz.py gdal2xyz.py
_gdaladdo()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list="--help --long-usage --help-general -r -ro --quiet -b -oo -minsize -clean --partial-refresh-from-source-timestamp --partial-refresh-from-projwin --partial-refresh-from-source-extent --version --build --license --formats --format --optfile --config --debug --pause --locale "
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
tool=${COMP_WORDS[0]}
case "$prev" in
--format)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
esac
return 0
}
complete -o default -F _gdaladdo gdaladdo
_gdalbuildvrt()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list="--help --long-usage --help-general --quiet -strict -non_strict -tile_index -resolution -tr -input_file_list -separate -allow_projection_difference -sd -tap -te -addalpha -b -hidenodata -overwrite -srcnodata -vrtnodata -a_srs -r -oo -co -ignore_srcmaskband -nodata_max_mask_threshold --version --build --license --formats --format --optfile --config --debug --pause --locale "
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
tool=${COMP_WORDS[0]}
case "$prev" in
--format)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
esac
return 0
}
complete -o default -F _gdalbuildvrt gdalbuildvrt
_gdal_calc.py()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list="--help --help-general -a --a_band -b --b_band -c --c_band -d --d_band -e --e_band -f --f_band -g --g_band -h --h_band -i --i_band -j --j_band -k --k_band -l --l_band -m --m_band -n --n_band -o --o_band -p --p_band -q --q_band -r --r_band -s --s_band -t --t_band -u --u_band -v --v_band -w --w_band -x --x_band -y --y_band -z --z_band -A --A_band -B --B_band -C --C_band -D --D_band -E --E_band -F --F_band -G --G_band -H --H_band -I --I_band -J --J_band -K --K_band -L --L_band -M --M_band -N --N_band -O --O_band -P --P_band -Q --Q_band -R --R_band -S --S_band -T --T_band -U --U_band -V --V_band -W --W_band -X --X_band -Y --Y_band -Z --Z_band --NoDataValue --hideNoData --type --format --creation-option --allBands --overwrite --debug --quiet --color-table --extent --projectionCheck --version --build --license --formats --optfile --config --pause --locale "
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
tool=${COMP_WORDS[0]}
case "$prev" in
-f)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
--format)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
esac
return 0
}
complete -o default -F _gdal_calc.py gdal_calc.py
_gdalcompare.py()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list="--help --help-general -dumpdiffs -skip_binary -skip_overviews -skip_geolocation -skip_geotransform -skip_metadata -skip_rpc -skip_srs -sds --version --build --license --formats --format --optfile --config --debug --pause --locale "
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
tool=${COMP_WORDS[0]}
case "$prev" in
--format)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
esac
return 0
}
complete -o default -F _gdalcompare.py gdalcompare.py
_gdal-config()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list="--prefix --libs --dep-libs --cflags --datadir --version --ogr-enabled --gnm-enabled --formats --plugindir "
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
return 0
}
complete -o default -F _gdal-config gdal-config
_gdal_contour()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list="--help --long-usage --help-general -b -a -amin -amax -3d -inodata -snodata -of -dsco -lco -i -e -fl -off -nln -p -gt --quiet --version --build --license --formats --format --optfile --config --debug --pause --locale "
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
tool=${COMP_WORDS[0]}
case "$prev" in
-of)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
--format)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
esac
return 0
}
complete -o default -F _gdal_contour gdal_contour
_gdaldem()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list="--help --long-usage --help-general --version --build --license --formats --format --optfile --config --debug --pause --locale "
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
tool=${COMP_WORDS[0]}
case "$prev" in
--format)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
esac
return 0
}
complete -o default -F _gdaldem gdaldem
_gdal_edit.py()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list="--help --help-general -ro -a_srs -a_ullr -a_ulurll -tr -unsetgt -unsetrpc -a_nodata -unsetnodata -offset -scale -units -colorinterp_<X> -a_coord_epoch -unsetepoch -unsetstats -stats -approx_stats -setstats -gcp -unsetmd -oo -mo --version --build --license --formats --format --optfile --config --debug --pause --locale "
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
tool=${COMP_WORDS[0]}
case "$prev" in
--format)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
esac
return 0
}
complete -o default -F _gdal_edit.py gdal_edit.py
_gdalenhance()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "$cur" in
-*)
key_list="--help --help-general -of -co -ot -equalize -config --version --build --license --formats --format --optfile --config --debug --pause --locale "
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
return 0
;;
esac
tool=${COMP_WORDS[0]}
case "$prev" in
-ot)
key_list="Byte Int16 UInt16 UInt32 Int32 Float32 Float64 CInt16 CInt32 CFloat32 CFloat64"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
-of)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
--format)
key_list="$( $tool --formats | tail -n +2 | cut -f 3 -d ' ')"
mapfile -t COMPREPLY < <(compgen -W "$key_list" -- "$cur")
;;
esac
return 0
}
complete -o default -F _gdalenhance gdalenhance