@@ -27,18 +27,24 @@ __pgbackrest_command_options_values() {
27
27
echo ${command_options_values}
28
28
}
29
29
30
- # The '--output' option is available for 2 commands ( 'repo-ls' and 'info') with the same values.
30
+ # The '--output' option is available for 'repo-ls' and 'info' commands with the same values.
31
31
# For 'repo-ls' command displayed additional information in the same format.
32
- # To simplify the solution, the option values are specified directly.
33
- # If the values for different commands will be different, this code must be reviewed.
32
+ # To simplify the solution and not write additional regexp, the option values are specified directly.
34
33
__pgbackrest_command_options_values_output () {
35
34
echo " text" $' \n ' " json"
36
35
}
37
36
37
+ # The '--output' option is available for 'verify' command with another values.
38
+ # As well as other formatting of the hint text.
39
+ # When new commands with unique options list appear, refactoring will be required.
40
+ __pgbackrest_command_options_values_output_verify () {
41
+ echo " none" $' \n ' " text"
42
+ }
43
+
38
44
# The '--buffer-size' displays values in the user friendly format starting from pgBackRest v2.37.
39
45
# In earlier versions, values in bytes will be substituted.
40
46
# https://github.com/pgbackrest/pgbackrest/pull/1557
41
- __pgbackrest_command_options_values_buffer_size (){
47
+ __pgbackrest_command_options_values_buffer_size () {
42
48
local buffer_size_option_values
43
49
# Regex for valid values like:
44
50
# 16384,
@@ -55,6 +61,12 @@ __pgbackrest_command_options_values_buffer_size(){
55
61
echo ${buffer_size_option_values[@]}
56
62
}
57
63
64
+ # The '--type' option for 'info' command has non-standard hint text formating for parsing.
65
+ # If the number of commands with non-standard hint text formating will grow, refactoring will be required.
66
+ __pgbackrest_command_options_values_type_info () {
67
+ echo " full" $' \n ' " incr" $' \n ' " diff"
68
+ }
69
+
58
70
# If no stanza - return empty string; nothing to complete.
59
71
# May be some delays in getting stanza names.
60
72
__pgbackrest_stanza_values () {
@@ -150,11 +162,29 @@ _pgbackrest() {
150
162
COMPREPLY=($( compgen -W " $( __pgbackrest_stanza_values) " -- ${cur} ) )
151
163
return 0;;
152
164
--output)
153
- COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values_output) " -- ${cur} ) )
154
- return 0;;
165
+ # Different values for the '--output' option depending on the command.
166
+ case ${COMP_WORDS[1]} in
167
+ verify)
168
+ COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values_output_verify) " -- ${cur} ) )
169
+ return 0;;
170
+ * )
171
+ COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values_output) " -- ${cur} ) )
172
+ return 0;;
173
+ esac ;;
155
174
--buffer-size)
156
175
COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values_buffer_size) " -- ${cur} ) )
157
176
return 0;;
177
+ --type)
178
+ # Different values for the '--type' option depending on the command.
179
+ case ${COMP_WORDS[1]} in
180
+ info)
181
+ COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values_backup_types) " -- ${cur} ) )
182
+ return 0;;
183
+ * )
184
+ # The usual completion for all other commands.
185
+ COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values) " -- ${cur} ) )
186
+ return 0;;
187
+ esac ;;
158
188
* )
159
189
if [[ ${prev} =~ ${arg_regex} ]]; then
160
190
COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values) " -- ${cur} ) )
@@ -186,11 +216,26 @@ _pgbackrest() {
186
216
COMPREPLY=($( compgen -W " $( __pgbackrest_stanza_values) " -- ${cur} ) )
187
217
return 0;;
188
218
--output)
189
- COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values_output) " -- ${cur} ) )
190
- return 0;;
219
+ case ${COMP_WORDS[1]} in
220
+ verify)
221
+ COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values_output_verify) " -- ${cur} ) )
222
+ return 0;;
223
+ * )
224
+ COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values_output) " -- ${cur} ) )
225
+ return 0;;
226
+ esac ;;
191
227
--buffer-size)
192
228
COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values_buffer_size) " -- ${cur} ) )
193
229
return 0;;
230
+ --type)
231
+ case ${COMP_WORDS[1]} in
232
+ info)
233
+ COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values_backup_types) " -- ${cur} ) )
234
+ return 0;;
235
+ * )
236
+ COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values) " -- ${cur} ) )
237
+ return 0;;
238
+ esac ;;
194
239
* )
195
240
if [[ ${prev} =~ ${arg_regex} ]]; then
196
241
COMPREPLY=($( compgen -W " $( __pgbackrest_command_options_values) " -- ${cur} ) )
0 commit comments