1
1
#! /bin/bash
2
2
3
- __base_test_cursor_index_in_current_word () {
3
+ __base-test_cursor_index_in_current_word () {
4
4
local remaining=" ${COMP_LINE} "
5
5
6
6
local word
@@ -33,7 +33,7 @@ __base_test_cursor_index_in_current_word() {
33
33
# - options: remove options for this (sub)command that are already on the command line
34
34
# - positional_number: set to the current positional number
35
35
# - unparsed_words: remove all flags, options, and option values for this (sub)command
36
- __base_test_offer_flags_options () {
36
+ __base-test_offer_flags_options () {
37
37
local -ir positional_count=" ${1} "
38
38
positional_number=0
39
39
@@ -125,14 +125,14 @@ __base_test_offer_flags_options() {
125
125
fi
126
126
}
127
127
128
- __base_test_add_completions () {
128
+ __base-test_add_completions () {
129
129
local completion
130
130
while IFS=' ' read -r completion; do
131
131
COMPREPLY+=(" ${completion} " )
132
132
done < <( IFS=$' \n ' compgen " ${@ } " -- " ${cur} " )
133
133
}
134
134
135
- __base_test_custom_complete () {
135
+ __base-test_custom_complete () {
136
136
if [[ -n " ${cur} " || -z ${COMP_WORDS[${COMP_CWORD}]} || " ${COMP_LINE: ${COMP_POINT} : 1} " != ' ' ]]; then
137
137
local -ar words=(" ${COMP_WORDS[@]} " )
138
138
else
@@ -142,7 +142,7 @@ __base_test_custom_complete() {
142
142
" ${COMP_WORDS[0]} " " ${@ } " " ${words[@]} "
143
143
}
144
144
145
- _base_test () {
145
+ _base-test () {
146
146
trap " $( shopt -p) ;$( shopt -po) " RETURN
147
147
shopt -s extglob
148
148
set +o history +o posix
@@ -160,31 +160,31 @@ _base_test() {
160
160
161
161
local -a flags=(--one --two --three --kind-counter -h --help)
162
162
local -a options=(--name --kind --other-kind --path1 --path2 --path3 --rep1 -r --rep2)
163
- __base_test_offer_flags_options 2
163
+ __base-test_offer_flags_options 2
164
164
165
165
# Offer option value completions
166
166
case " ${prev} " in
167
167
--name)
168
168
return
169
169
;;
170
170
--kind)
171
- __base_test_add_completions -W ' one' $' \n ' ' two' $' \n ' ' custom-three'
171
+ __base-test_add_completions -W ' one' $' \n ' ' two' $' \n ' ' custom-three'
172
172
return
173
173
;;
174
174
--other-kind)
175
- __base_test_add_completions -W ' b1_bash' $' \n ' ' b2_bash' $' \n ' ' b3_bash'
175
+ __base-test_add_completions -W ' b1_bash' $' \n ' ' b2_bash' $' \n ' ' b3_bash'
176
176
return
177
177
;;
178
178
--path1)
179
- __base_test_add_completions -f
179
+ __base-test_add_completions -f
180
180
return
181
181
;;
182
182
--path2)
183
- __base_test_add_completions -f
183
+ __base-test_add_completions -f
184
184
return
185
185
;;
186
186
--path3)
187
- __base_test_add_completions -W ' c1_bash' $' \n ' ' c2_bash' $' \n ' ' c3_bash'
187
+ __base-test_add_completions -W ' c1_bash' $' \n ' ' c2_bash' $' \n ' ' c3_bash'
188
188
return
189
189
;;
190
190
--rep1)
@@ -198,11 +198,11 @@ _base_test() {
198
198
# Offer positional completions
199
199
case " ${positional_number} " in
200
200
1)
201
- __base_test_add_completions -W " $( __base_test_custom_complete ---completion -- argument " ${COMP_CWORD} " " $( __base_test_cursor_index_in_current_word ) " ) "
201
+ __base-test_add_completions -W " $( __base-test_custom_complete ---completion -- positional@0 " ${COMP_CWORD} " " $( __base-test_cursor_index_in_current_word ) " ) "
202
202
return
203
203
;;
204
204
2)
205
- __base_test_add_completions -W " $( __base_test_custom_complete ---completion -- nested.nestedArgument " ${COMP_CWORD} " " $( __base_test_cursor_index_in_current_word ) " ) "
205
+ __base-test_add_completions -W " $( __base-test_custom_complete ---completion -- positional@1 " ${COMP_CWORD} " " $( __base-test_cursor_index_in_current_word ) " ) "
206
206
return
207
207
;;
208
208
esac
@@ -214,7 +214,7 @@ _base_test() {
214
214
case " ${subcommand} " in
215
215
sub-command|escaped-command|help)
216
216
# Offer subcommand argument completions
217
- " _base_test_ ${subcommand} "
217
+ " _base-test_ ${subcommand} "
218
218
;;
219
219
* )
220
220
# Offer subcommand completions
@@ -223,16 +223,16 @@ _base_test() {
223
223
esac
224
224
}
225
225
226
- _base_test_sub_command () {
226
+ _base-test_sub-command () {
227
227
flags=(-h --help)
228
228
options=()
229
- __base_test_offer_flags_options 0
229
+ __base-test_offer_flags_options 0
230
230
}
231
231
232
- _base_test_escaped_command () {
232
+ _base-test_escaped-command () {
233
233
flags=(-h --help)
234
234
options=(--one)
235
- __base_test_offer_flags_options 1
235
+ __base-test_offer_flags_options 1
236
236
237
237
# Offer option value completions
238
238
case " ${prev} " in
@@ -244,14 +244,14 @@ _base_test_escaped_command() {
244
244
# Offer positional completions
245
245
case " ${positional_number} " in
246
246
1)
247
- __base_test_add_completions -W " $( __base_test_custom_complete ---completion escaped-command -- two " ${COMP_CWORD} " " $( __base_test_cursor_index_in_current_word ) " ) "
247
+ __base-test_add_completions -W " $( __base-test_custom_complete ---completion escaped-command -- positional@0 " ${COMP_CWORD} " " $( __base-test_cursor_index_in_current_word ) " ) "
248
248
return
249
249
;;
250
250
esac
251
251
}
252
252
253
- _base_test_help () {
253
+ _base-test_help () {
254
254
:
255
255
}
256
256
257
- complete -o filenames -F _base_test base-test
257
+ complete -o filenames -F _base-test base-test
0 commit comments