@drfed/drfed 0.1.0 → 0.2.0-dev.605
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/completions/bash/drfed-account +529 -30
- package/completions/bash/drfed-migrate +529 -30
- package/completions/bash/drfed-server +529 -30
- package/completions/bash/drfed-web +529 -30
- package/completions/fish/drfed-account.fish +137 -49
- package/completions/fish/drfed-migrate.fish +137 -49
- package/completions/fish/drfed-server.fish +137 -49
- package/completions/fish/drfed-web.fish +137 -49
- package/completions/nu/drfed-account.nu +303 -73
- package/completions/nu/drfed-migrate.nu +303 -73
- package/completions/nu/drfed-server.nu +303 -73
- package/completions/nu/drfed-web.nu +303 -73
- package/completions/pwsh/drfed-account.ps1 +153 -34
- package/completions/pwsh/drfed-migrate.ps1 +153 -34
- package/completions/pwsh/drfed-server.ps1 +153 -34
- package/completions/pwsh/drfed-web.ps1 +153 -34
- package/completions/zsh/_drfed-account +532 -34
- package/completions/zsh/_drfed-migrate +532 -34
- package/completions/zsh/_drfed-server +532 -34
- package/completions/zsh/_drfed-web +532 -34
- package/dist/api-mail-parser.d.mts.map +1 -1
- package/dist/commands/account-program.d.mts.map +1 -1
- package/dist/commands/account.mjs +6 -4
- package/dist/commands/account.mjs.map +1 -1
- package/dist/commands/migrate-program.d.mts.map +1 -1
- package/dist/commands/migrate.mjs +6 -4
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/web-program.d.mts.map +1 -1
- package/dist/commands/web.mjs +7 -5
- package/dist/commands/web.mjs.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/jmap-parser.d.mts.map +1 -1
- package/dist/logging.d.mts.map +1 -1
- package/dist/mail-parser-DyI4wuQp.d.mts.map +1 -1
- package/dist/mail-runtime.mjs +1 -2
- package/dist/mail-settings-DjWMAUaE.d.mts.map +1 -1
- package/dist/mail-settings.mjs +1 -2
- package/dist/operations.mjs.map +1 -1
- package/dist/package-BRpsF5SF.mjs +6 -0
- package/dist/package-BRpsF5SF.mjs.map +1 -0
- package/dist/parser-TANGHRjL.d.mts.map +1 -1
- package/dist/resources.mjs.map +1 -1
- package/package.json +18 -18
- package/dist/package-7FOUqcPO.mjs +0 -6
- package/dist/package-7FOUqcPO.mjs.map +0 -1
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
#compdef drfed-migrate
|
|
2
|
-
function
|
|
3
|
-
|
|
2
|
+
function _optique:drfed-migrate () {
|
|
3
|
+
# Completion fields omit surrounding quotes, unlike words[CURRENT].
|
|
4
|
+
# Single-quoted fields are already literal; other fields retain escapes.
|
|
5
|
+
local current="$IPREFIX$PREFIX$SUFFIX$ISUFFIX"
|
|
6
|
+
local __logical_prefix="$IPREFIX$PREFIX"
|
|
7
|
+
# Let zsh match the suffix when completing in the middle of a word.
|
|
8
|
+
if [[ -o complete_in_word ]]; then
|
|
9
|
+
current="$__logical_prefix"
|
|
10
|
+
fi
|
|
11
|
+
if [[ "$compstate[quote]" == '"' ]]; then
|
|
12
|
+
# Restore the omitted quoting context before removing shell escapes.
|
|
13
|
+
# In double quotes, a backslash before an ordinary character is literal.
|
|
14
|
+
current="$QIPREFIX$current${QISUFFIX:-$compstate[quote]}"
|
|
15
|
+
__logical_prefix="$QIPREFIX$__logical_prefix$compstate[quote]"
|
|
16
|
+
current="${(Q)current}"
|
|
17
|
+
__logical_prefix="${(Q)__logical_prefix}"
|
|
18
|
+
elif [[ "$compstate[quote]" != "'" ]]; then
|
|
19
|
+
current="${(Q)current}"
|
|
20
|
+
__logical_prefix="${(Q)__logical_prefix}"
|
|
21
|
+
fi
|
|
4
22
|
local -a prev
|
|
5
23
|
# Extract previous arguments, skipping empty ones
|
|
6
24
|
prev=()
|
|
7
25
|
local i
|
|
8
26
|
for (( i=2; i < CURRENT; i++ )); do
|
|
9
27
|
if [[ -n "$words[i]" ]]; then
|
|
10
|
-
prev+=("$words[i]")
|
|
28
|
+
prev+=("${(Q)words[i]}")
|
|
11
29
|
fi
|
|
12
30
|
done
|
|
13
31
|
|
|
@@ -31,11 +49,34 @@ function _drfed_migrate () {
|
|
|
31
49
|
desc=${line#*$'\0'}
|
|
32
50
|
desc=${desc%%$'\0'*}
|
|
33
51
|
|
|
34
|
-
|
|
52
|
+
local __literal=0
|
|
53
|
+
if [[ "$value" == __LITERAL__:* ]]; then
|
|
54
|
+
value="${value#__LITERAL__:}"
|
|
55
|
+
__literal=1
|
|
56
|
+
fi
|
|
57
|
+
if [[ $__literal == 0 && "$value" == __FILE__:* ]]; then
|
|
35
58
|
# Parse file completion directive: __FILE__:type:extensions:pattern:hidden
|
|
36
|
-
local type extensions pattern hidden
|
|
37
|
-
IFS=':' read -r _ type extensions pattern hidden <<< "$value"
|
|
38
|
-
|
|
59
|
+
local type extensions pattern hidden insertion_prefix
|
|
60
|
+
IFS=':' read -r _ type extensions pattern hidden insertion_prefix <<< "$value"
|
|
61
|
+
local __decoded_pattern="$pattern"
|
|
62
|
+
__decoded_pattern="${__decoded_pattern//\%3A/:}"; __decoded_pattern="${__decoded_pattern//\%25/%}"
|
|
63
|
+
insertion_prefix="${insertion_prefix//\%3A/:}"; insertion_prefix="${insertion_prefix//\%25/%}"
|
|
64
|
+
local __saved_prefix="$PREFIX" __saved_iprefix="$IPREFIX"
|
|
65
|
+
local __saved_current="$current" __saved_logical_prefix="$__logical_prefix"
|
|
66
|
+
if [[ -n "$insertion_prefix" && "$__decoded_pattern" == "$insertion_prefix"* &&
|
|
67
|
+
"$PREFIX" == "$insertion_prefix"* &&
|
|
68
|
+
"$__logical_prefix" == "$insertion_prefix"* &&
|
|
69
|
+
"$current" == "$insertion_prefix"* ]]; then
|
|
70
|
+
pattern="${__decoded_pattern#"$insertion_prefix"}"
|
|
71
|
+
PREFIX="${PREFIX#"$insertion_prefix"}"
|
|
72
|
+
IPREFIX="$IPREFIX$insertion_prefix"
|
|
73
|
+
# Compare file patterns with the value part, not the inserted key.
|
|
74
|
+
current="${current#"$insertion_prefix"}"
|
|
75
|
+
__logical_prefix="${__logical_prefix#"$insertion_prefix"}"
|
|
76
|
+
else
|
|
77
|
+
# Preserve legacy decoding for directives without active metadata.
|
|
78
|
+
pattern="${pattern//%3A/:}"; pattern="${pattern//%25/%}"
|
|
79
|
+
fi
|
|
39
80
|
has_file_completion=1
|
|
40
81
|
|
|
41
82
|
# Native completion helpers expect normal zsh glob grouping even if
|
|
@@ -43,6 +84,11 @@ function _drfed_migrate () {
|
|
|
43
84
|
local __was_sh_glob=0
|
|
44
85
|
[[ -o sh_glob ]] && __was_sh_glob=1
|
|
45
86
|
unsetopt sh_glob
|
|
87
|
+
local __was_extended_glob=0
|
|
88
|
+
[[ -o extended_glob ]] && __was_extended_glob=1
|
|
89
|
+
local __was_sh_word_split=0
|
|
90
|
+
[[ -o sh_word_split ]] && __was_sh_word_split=1
|
|
91
|
+
unsetopt sh_word_split
|
|
46
92
|
|
|
47
93
|
# Enable glob_dots when hidden files are requested so that
|
|
48
94
|
# _files and _directories include dot-prefixed entries
|
|
@@ -54,21 +100,351 @@ function _drfed_migrate () {
|
|
|
54
100
|
# _directories enumerate the pattern's directory instead of the
|
|
55
101
|
# current word. If the user has already typed beyond the pattern,
|
|
56
102
|
# keep PREFIX unchanged for incremental narrowing.
|
|
57
|
-
local
|
|
58
|
-
|
|
103
|
+
local __fixed_glob=0
|
|
104
|
+
local -a __fixed_matches
|
|
105
|
+
local __initial_file_pattern="" __initial_directory="" __initial_leaf=""
|
|
106
|
+
if [[ ( "$type" == "file" || "$type" == "any" || "$type" == "directory" ) &&
|
|
107
|
+
-z "$current$PREFIX$SUFFIX" &&
|
|
108
|
+
-z "${compstate[pattern_match]}" &&
|
|
109
|
+
"$pattern" != /* && "$pattern" != "~"* ]]; then
|
|
110
|
+
if [[ "$pattern" == */* ]]; then
|
|
111
|
+
__initial_directory="${pattern%/*}/"
|
|
112
|
+
fi
|
|
113
|
+
__initial_leaf="${pattern##*/}"
|
|
114
|
+
# Native -g filters are split as shell words and use extended glob
|
|
115
|
+
# syntax. Keep unsupported filename forms on the existing path.
|
|
116
|
+
if [[ "$__initial_leaf" == *[*?]* &&
|
|
117
|
+
"$__initial_directory" != *[*?]* &&
|
|
118
|
+
"$__initial_directory" != *["[]()"]* &&
|
|
119
|
+
"$__initial_leaf" != *["[]"]* &&
|
|
120
|
+
"$__initial_leaf" != *'\'* &&
|
|
121
|
+
"$__initial_leaf" != *[[:space:]]* &&
|
|
122
|
+
"$__initial_leaf" != *["#~^()|<>;&"]* &&
|
|
123
|
+
"$__initial_leaf" != *"'"* && "$__initial_leaf" != *'"'* ]]; then
|
|
124
|
+
__initial_file_pattern="$__initial_leaf"
|
|
125
|
+
# Only the literal directory belongs in PREFIX. Quote it so
|
|
126
|
+
# spaces and shell metacharacters remain literal path text.
|
|
127
|
+
if [[ -n "$__initial_directory" ]]; then
|
|
128
|
+
PREFIX="${(q)__initial_directory}"
|
|
129
|
+
fi
|
|
130
|
+
fi
|
|
131
|
+
fi
|
|
132
|
+
local __saved_pattern_match="$compstate[pattern_match]"
|
|
133
|
+
local __pattern_match_changed=0
|
|
134
|
+
# path() echoes current as its pattern. Keep zsh's escaped PREFIX
|
|
135
|
+
# in that case instead of reinterpreting logical text as shell syntax.
|
|
136
|
+
if [[ -n "$pattern" && "$pattern" != "$current" && -z "$__initial_file_pattern" ]]; then
|
|
59
137
|
# Normalize leading ./ so that ./src/ma matches pattern src/
|
|
60
|
-
local __norm_prefix="${
|
|
138
|
+
local __norm_prefix="${__logical_prefix#./}"
|
|
61
139
|
local __norm_pattern="${pattern#./}"
|
|
62
140
|
local __compare_pattern="$__norm_pattern"
|
|
63
141
|
if [[ "$__compare_pattern" == *[*?]* ]]; then
|
|
64
142
|
__compare_pattern="${__compare_pattern%%[*?]*}"
|
|
65
143
|
[[ "$__compare_pattern" == */* ]] && __compare_pattern="${__compare_pattern%/*}/" || __compare_pattern=""
|
|
66
144
|
fi
|
|
67
|
-
if [[ ( -n "$__compare_pattern" || -n "$__norm_prefix" ) && ${#__norm_prefix} -ge ${#__compare_pattern} && "${__norm_prefix[1,${#__compare_pattern}]}" == "$__compare_pattern" && "$
|
|
68
|
-
#
|
|
69
|
-
|
|
145
|
+
if [[ ( -n "$__compare_pattern" || -n "$__norm_prefix" ) && ${#__norm_prefix} -ge ${#__compare_pattern} && "${__norm_prefix[1,${#__compare_pattern}]}" == "$__compare_pattern" && "$__logical_prefix" != "$pattern" ]]; then
|
|
146
|
+
# Keep the typed prefix, but retain a fixed file glob separately.
|
|
147
|
+
if [[ "$type" != "directory" && "$__norm_pattern" == *[*?]* ]]; then
|
|
148
|
+
__fixed_glob=1
|
|
149
|
+
local __fixed_was_glob_dots=0
|
|
150
|
+
[[ -o glob_dots ]] && __fixed_was_glob_dots=1
|
|
151
|
+
if [[ "$PREFIX" == .* || "$PREFIX" == */.* ]]; then setopt glob_dots; fi
|
|
152
|
+
# Keep qualifiers in a string so sourcing also works with SH_GLOB.
|
|
153
|
+
local __fixed_pattern="" __glob_char="" __glob_previous=""
|
|
154
|
+
local __glob_escaped=0
|
|
155
|
+
local __glob_class=0 __glob_class_start=0 __glob_class_nested=""
|
|
156
|
+
local -i __glob_index
|
|
157
|
+
for (( __glob_index=1; __glob_index <= ${#pattern}; __glob_index++ )); do
|
|
158
|
+
__glob_char="${pattern[__glob_index]}"
|
|
159
|
+
if [[ "$__glob_class" == "1" ]]; then
|
|
160
|
+
# Class members are already literal. Preserve leading ]
|
|
161
|
+
# and nested POSIX classes without adding backslashes.
|
|
162
|
+
__fixed_pattern+="$__glob_char"
|
|
163
|
+
if [[ -n "$__glob_class_nested" ]]; then
|
|
164
|
+
if [[ "$__glob_char" == "]" && "$__glob_previous" == "$__glob_class_nested" ]]; then
|
|
165
|
+
__glob_class_nested=""
|
|
166
|
+
fi
|
|
167
|
+
elif [[ "$__glob_char" == "[" && "${pattern[__glob_index+1]}" == ":" ]]; then
|
|
168
|
+
__glob_class_nested="${pattern[__glob_index+1]}"
|
|
169
|
+
__glob_class_start=0
|
|
170
|
+
elif [[ "$__glob_char" == "]" && "$__glob_class_start" == "0" ]]; then
|
|
171
|
+
__glob_class=0
|
|
172
|
+
elif [[ "$__glob_class_start" == "1" && ( "$__glob_char" == "!" || "$__glob_char" == "^" ) &&
|
|
173
|
+
( "${pattern[__glob_index+1]}" != "]" || "${pattern[__glob_index+2,-1]}" == *']'* ) ]]; then
|
|
174
|
+
__glob_class_start=2
|
|
175
|
+
else
|
|
176
|
+
__glob_class_start=0
|
|
177
|
+
fi
|
|
178
|
+
__glob_previous="$__glob_char"
|
|
179
|
+
continue
|
|
180
|
+
fi
|
|
181
|
+
if [[ "$__glob_escaped" == "1" ]]; then
|
|
182
|
+
__fixed_pattern+="$__glob_char"
|
|
183
|
+
__glob_escaped=0
|
|
184
|
+
__glob_previous=""
|
|
185
|
+
continue
|
|
186
|
+
fi
|
|
187
|
+
if [[ "$__glob_char" == "\\" ]]; then
|
|
188
|
+
__fixed_pattern+="$__glob_char"
|
|
189
|
+
__glob_escaped=1
|
|
190
|
+
elif [[ "$__glob_char" == "[" ]]; then
|
|
191
|
+
__fixed_pattern+="$__glob_char"
|
|
192
|
+
__glob_class=1
|
|
193
|
+
__glob_class_start=1
|
|
194
|
+
elif [[ "$__glob_char" == [#^~\(\)\|\<\>] &&
|
|
195
|
+
! ( "$__glob_char" == "~" && "$__glob_index" == "1" ) ]]; then
|
|
196
|
+
# Keep class negation and leading home expansion; escape
|
|
197
|
+
# extended-glob operators in literal pathname components.
|
|
198
|
+
__fixed_pattern+="\\$__glob_char"
|
|
199
|
+
else
|
|
200
|
+
__fixed_pattern+="$__glob_char"
|
|
201
|
+
fi
|
|
202
|
+
__glob_previous="$__glob_char"
|
|
203
|
+
done
|
|
204
|
+
__fixed_pattern+="(#qN)"
|
|
205
|
+
__fixed_matches=( ${~__fixed_pattern} )
|
|
206
|
+
__fixed_matches=( "${(@)__fixed_matches:a}" )
|
|
207
|
+
# Hidden parents widen fixed matches, not native child suggestions.
|
|
208
|
+
if [[ "$__fixed_was_glob_dots" == "0" && "${PREFIX##*/}" != .* ]]; then unsetopt glob_dots; fi
|
|
209
|
+
fi
|
|
70
210
|
else
|
|
71
|
-
|
|
211
|
+
local __native_pattern="$pattern"
|
|
212
|
+
# Initial globs use the conservative native filters above.
|
|
213
|
+
# Retained input and protected markers still need pattern matching.
|
|
214
|
+
if [[ -n "$compstate[context]" && "$pattern" == *[\*\?\[]* &&
|
|
215
|
+
( -n "$current" || "$pattern" == *'$'* || "$pattern" == *'`'* ) ]]; then
|
|
216
|
+
compstate[pattern_match]='*'
|
|
217
|
+
__pattern_match_changed=1
|
|
218
|
+
fi
|
|
219
|
+
# Native helpers expand substitutions, tilde names and executable
|
|
220
|
+
# glob qualifiers. Input-derived patterns must keep these literal.
|
|
221
|
+
# Ordinary fixed glob/tilde patterns retain their native behavior.
|
|
222
|
+
local __tilde_name="${pattern#\~}"
|
|
223
|
+
__tilde_name="${__tilde_name%%/*}"
|
|
224
|
+
local -a match mbegin mend
|
|
225
|
+
local __code_qualifier=0
|
|
226
|
+
local __fixed_qualifier_base=""
|
|
227
|
+
local __safe_qualifiers='([-/F.@=p*rwxAIERWXsStUG^MTNDn,]|[ugdl]<->|[amc]([Mwhmsd]|)([-+]|)<->|L([kKmMgGtTpP]|)([-+]|)<->|[oO][nLlamcdN])##'
|
|
228
|
+
local __qualifier_pattern="$pattern" __qualifier
|
|
229
|
+
while _have_glob_qual "$__qualifier_pattern" complete; do
|
|
230
|
+
__qualifier="${match[5]#\#q}"
|
|
231
|
+
__qualifier_pattern="$match[2]"
|
|
232
|
+
# A numeric sense (+1) is not a function qualifier (+name).
|
|
233
|
+
# Accept only bounded attribute/sort syntax in this exception.
|
|
234
|
+
# Expand the pattern at runtime after unsetting SH_GLOB.
|
|
235
|
+
if [[ "$__qualifier" == ${~__safe_qualifiers} ]]; then
|
|
236
|
+
__fixed_qualifier_base="$__qualifier_pattern"
|
|
237
|
+
elif [[ "$__qualifier" == *[e+]* ]]; then
|
|
238
|
+
__code_qualifier=1
|
|
239
|
+
fi
|
|
240
|
+
done
|
|
241
|
+
# Partial overlaps with complete backend classes/groups remain
|
|
242
|
+
# syntax. A complete input-provided expression can be literal.
|
|
243
|
+
local -a __syntax_starts=() __syntax_ends=() __group_stack=()
|
|
244
|
+
local -i __scan_index __class_begin=0 __member_begin=0
|
|
245
|
+
local __scan_char __nested_class=""
|
|
246
|
+
for (( __scan_index=1; __scan_index <= ${#pattern}; __scan_index++ )); do
|
|
247
|
+
__scan_char="${pattern[__scan_index]}"
|
|
248
|
+
if [[ "$__scan_char" == '\' ]]; then
|
|
249
|
+
(( __scan_index++ ))
|
|
250
|
+
elif (( __class_begin )); then
|
|
251
|
+
if [[ "$__scan_char" == '[' && "${pattern[__scan_index+1]}" == [:.=] ]]; then
|
|
252
|
+
__nested_class="${pattern[__scan_index+1]}"
|
|
253
|
+
elif [[ -n "$__nested_class" && "$__scan_char" == "$__nested_class" && "${pattern[__scan_index+1]}" == ']' ]]; then
|
|
254
|
+
(( __scan_index++ ))
|
|
255
|
+
__nested_class=""
|
|
256
|
+
elif [[ -z "$__nested_class" && "$__scan_char" == ']' ]] && (( __scan_index > __member_begin )); then
|
|
257
|
+
__syntax_starts+=("$__class_begin")
|
|
258
|
+
__syntax_ends+=("$__scan_index")
|
|
259
|
+
__class_begin=0
|
|
260
|
+
elif (( __scan_index == __member_begin )) &&
|
|
261
|
+
[[ "$__scan_char" == '!' || "$__scan_char" == '^' ]] &&
|
|
262
|
+
[[ "${pattern[__scan_index+1]}" != ']' || "${pattern[__scan_index+2,-1]}" == *']'* ]]; then
|
|
263
|
+
(( __member_begin++ ))
|
|
264
|
+
fi
|
|
265
|
+
elif [[ "$__scan_char" == '[' ]]; then
|
|
266
|
+
__class_begin=$__scan_index
|
|
267
|
+
__member_begin=$(( __scan_index + 1 ))
|
|
268
|
+
elif [[ "$__scan_char" == '(' ]]; then
|
|
269
|
+
__group_stack+=("$__scan_index")
|
|
270
|
+
elif [[ "$__scan_char" == ')' ]] && (( ${#__group_stack} )); then
|
|
271
|
+
__syntax_starts+=("${__group_stack[-1]}")
|
|
272
|
+
__syntax_ends+=("$__scan_index")
|
|
273
|
+
__group_stack[-1]=()
|
|
274
|
+
fi
|
|
275
|
+
done
|
|
276
|
+
# Search retained input only where it cannot split fixed syntax.
|
|
277
|
+
local __input_part="$current"
|
|
278
|
+
local __backend_prefix="$pattern" __backend_suffix=""
|
|
279
|
+
local __search_pattern __candidate_prefix
|
|
280
|
+
local -i __search_offset __overlap_start __overlap_end __range_index __syntax_overlap
|
|
281
|
+
local -i __fixed_tilde_end=0
|
|
282
|
+
local __tilde_expression='([+-]|[+-]<->|[[:alnum:]_.-]#)'
|
|
283
|
+
if [[ "$pattern" == '~'* &&
|
|
284
|
+
"$__tilde_name" == ${~__tilde_expression} ]]; then
|
|
285
|
+
__fixed_tilde_end=$(( ${#__tilde_name} + 1 ))
|
|
286
|
+
fi
|
|
287
|
+
while [[ -n "$__input_part" ]]; do
|
|
288
|
+
__search_pattern="$pattern"
|
|
289
|
+
__search_offset=0
|
|
290
|
+
while [[ "$__search_pattern" == *"$__input_part"* ]]; do
|
|
291
|
+
__candidate_prefix="${__search_pattern%%"$__input_part"*}"
|
|
292
|
+
__overlap_start=$(( __search_offset + ${#__candidate_prefix} + 1 ))
|
|
293
|
+
__overlap_end=$(( __overlap_start + ${#__input_part} - 1 ))
|
|
294
|
+
__syntax_overlap=0
|
|
295
|
+
# Leading home/directory-stack/named-directory syntax belongs
|
|
296
|
+
# to the fixed pattern, even when the input overlaps it.
|
|
297
|
+
if (( __fixed_tilde_end && __overlap_start <= __fixed_tilde_end )); then
|
|
298
|
+
__syntax_overlap=1
|
|
299
|
+
fi
|
|
300
|
+
for (( __range_index=1; __range_index <= ${#__syntax_starts}; __range_index++ )); do
|
|
301
|
+
if (( __overlap_start <= __syntax_ends[__range_index] &&
|
|
302
|
+
__overlap_end >= __syntax_starts[__range_index] &&
|
|
303
|
+
( __overlap_start > __syntax_starts[__range_index] ||
|
|
304
|
+
__overlap_end < __syntax_ends[__range_index] ) )); then
|
|
305
|
+
__syntax_overlap=1
|
|
306
|
+
break
|
|
307
|
+
fi
|
|
308
|
+
done
|
|
309
|
+
# Every position in a recognized fixed attribute qualifier
|
|
310
|
+
# is backend syntax, including its closing parenthesis.
|
|
311
|
+
if [[ "$__fixed_qualifier_base" == *[\*\?\]] ]] &&
|
|
312
|
+
(( __overlap_end > ${#__fixed_qualifier_base} )); then
|
|
313
|
+
__syntax_overlap=1
|
|
314
|
+
fi
|
|
315
|
+
if (( ! __syntax_overlap )); then
|
|
316
|
+
if (( __overlap_start == 1 )); then
|
|
317
|
+
__backend_prefix=""
|
|
318
|
+
else
|
|
319
|
+
__backend_prefix="${pattern[1,__overlap_start-1]}"
|
|
320
|
+
fi
|
|
321
|
+
__backend_suffix="${pattern[__overlap_end+1,-1]}"
|
|
322
|
+
break 2
|
|
323
|
+
fi
|
|
324
|
+
__search_offset=$__overlap_start
|
|
325
|
+
__search_pattern="${pattern[__overlap_start+1,-1]}"
|
|
326
|
+
done
|
|
327
|
+
__input_part="${__input_part[2,-1]}"
|
|
328
|
+
done
|
|
329
|
+
local __quoted_input="${(q)__input_part}"
|
|
330
|
+
# Pattern matching removes quoting differently from normal
|
|
331
|
+
# completion. Character classes keep these characters literal.
|
|
332
|
+
if [[ -n "$compstate[pattern_match]" ]]; then
|
|
333
|
+
__quoted_input="${(b)__input_part}"
|
|
334
|
+
__quoted_input="${__quoted_input//\$/[\$]}"
|
|
335
|
+
__quoted_input="${__quoted_input//\`/[\`]}"
|
|
336
|
+
fi
|
|
337
|
+
if [[ "$pattern" == *'$'* || "$pattern" == *'`'* ||
|
|
338
|
+
( "$pattern" == '~'* && "$__tilde_name" == *[^[:alnum:]_.+-]* ) ]] ||
|
|
339
|
+
(( __code_qualifier )); then
|
|
340
|
+
__native_pattern="${(q)pattern}"
|
|
341
|
+
local __backend_pattern="$__backend_prefix$__backend_suffix"
|
|
342
|
+
local __backend_tilde="${__backend_pattern#\~}"
|
|
343
|
+
__backend_tilde="${__backend_tilde%%/*}"
|
|
344
|
+
local __unsafe_backend_qualifier=0
|
|
345
|
+
__qualifier_pattern="$__backend_pattern"
|
|
346
|
+
while _have_glob_qual "$__qualifier_pattern" complete; do
|
|
347
|
+
__qualifier="${match[5]#\#q}"
|
|
348
|
+
__qualifier_pattern="$match[2]"
|
|
349
|
+
if [[ "$__qualifier" != ${~__safe_qualifiers} ]]; then
|
|
350
|
+
__unsafe_backend_qualifier=1
|
|
351
|
+
fi
|
|
352
|
+
done
|
|
353
|
+
# Retain trusted wildcards and safe attribute qualifiers when
|
|
354
|
+
# all executable syntax belongs to the quoted input.
|
|
355
|
+
if [[ -n "$__input_part" &&
|
|
356
|
+
"$__backend_pattern" != *'$'* &&
|
|
357
|
+
"$__backend_pattern" != *'`'* &&
|
|
358
|
+
( "$__backend_pattern" != '~'* ||
|
|
359
|
+
"$__backend_tilde" != *[^[:alnum:]_.+-]* ) ]] &&
|
|
360
|
+
(( ! __unsafe_backend_qualifier )); then
|
|
361
|
+
__native_pattern="$__backend_prefix$__quoted_input$__backend_suffix"
|
|
362
|
+
elif [[ "$__backend_pattern" != *'$('* &&
|
|
363
|
+
"$__backend_pattern" != *'${'* &&
|
|
364
|
+
"$__backend_pattern" != *'$['* &&
|
|
365
|
+
( "$pattern" != '~'* ||
|
|
366
|
+
"$__tilde_name" != *[^[:alnum:]_.+-]* ) ]] &&
|
|
367
|
+
(( ! __unsafe_backend_qualifier )); then
|
|
368
|
+
# Fixed patterns also need literal substitution markers,
|
|
369
|
+
# without quoting their wildcards or safe qualifiers.
|
|
370
|
+
local __dollar='\$'
|
|
371
|
+
local __backtick='\`'
|
|
372
|
+
if [[ -n "$compstate[pattern_match]" ]]; then
|
|
373
|
+
__dollar='[$]'
|
|
374
|
+
__backtick='[`]'
|
|
375
|
+
fi
|
|
376
|
+
# Existing glob classes already protect their markers.
|
|
377
|
+
local -a __backend_parts=()
|
|
378
|
+
local __part __escaped __char __class_kind
|
|
379
|
+
local -i __index __in_class __class_start
|
|
380
|
+
for __part in "$__backend_prefix" "$__backend_suffix"; do
|
|
381
|
+
__escaped=""
|
|
382
|
+
__in_class=0
|
|
383
|
+
__class_kind=""
|
|
384
|
+
for (( __index=1; __index <= ${#__part}; __index++ )); do
|
|
385
|
+
__char="${__part[__index]}"
|
|
386
|
+
if [[ "$__char" == '\' ]]; then
|
|
387
|
+
__escaped+="$__char${__part[__index+1]}"
|
|
388
|
+
(( __index++ ))
|
|
389
|
+
continue
|
|
390
|
+
elif (( __in_class )); then
|
|
391
|
+
if [[ "$__char" == '[' && "${__part[__index+1]}" == [:.=] ]]; then
|
|
392
|
+
__class_kind="${__part[__index+1]}"
|
|
393
|
+
elif [[ -n "$__class_kind" && "$__char" == "$__class_kind" && "${__part[__index+1]}" == ']' ]]; then
|
|
394
|
+
__escaped+="$__char]"
|
|
395
|
+
(( __index++ ))
|
|
396
|
+
__class_kind=""
|
|
397
|
+
continue
|
|
398
|
+
elif [[ -z "$__class_kind" && "$__char" == ']' ]] && (( __index > __class_start )); then
|
|
399
|
+
__in_class=0
|
|
400
|
+
elif (( __index == __class_start )) && [[ "$__char" == '!' || "$__char" == '^' ]]; then
|
|
401
|
+
(( __class_start++ ))
|
|
402
|
+
fi
|
|
403
|
+
elif [[ "$__char" == '[' ]]; then
|
|
404
|
+
__in_class=1
|
|
405
|
+
__class_start=$(( __index + 1 ))
|
|
406
|
+
elif [[ "$__char" == '$' ]]; then
|
|
407
|
+
__char="$__dollar"
|
|
408
|
+
elif [[ "$__char" == '`' ]]; then
|
|
409
|
+
__char="$__backtick"
|
|
410
|
+
fi
|
|
411
|
+
__escaped+="$__char"
|
|
412
|
+
done
|
|
413
|
+
__backend_parts+=("$__escaped")
|
|
414
|
+
done
|
|
415
|
+
__backend_prefix="${__backend_parts[1]}"
|
|
416
|
+
__backend_suffix="${__backend_parts[2]}"
|
|
417
|
+
__native_pattern="$__backend_prefix$__quoted_input$__backend_suffix"
|
|
418
|
+
fi
|
|
419
|
+
else
|
|
420
|
+
# Quote retained metacharacters, including segments made only
|
|
421
|
+
# of them. Wildcard-only overlap remains backend syntax.
|
|
422
|
+
if [[ "$__input_part" == *[\\\(\)\[\#\^\|\~\<\>\*\?]* &&
|
|
423
|
+
"$__input_part" != [\*\?]## ]]; then
|
|
424
|
+
__native_pattern="$__backend_prefix$__quoted_input$__backend_suffix"
|
|
425
|
+
fi
|
|
426
|
+
fi
|
|
427
|
+
PREFIX="$__native_pattern"
|
|
428
|
+
# Match simple fixed tilde globs through native -g filters. The
|
|
429
|
+
# pattern matcher otherwise treats the leading ~ as glob syntax,
|
|
430
|
+
# even after _path_files has expanded it for filesystem lookup.
|
|
431
|
+
if (( __fixed_tilde_end )) && [[ -z "$__input_part" &&
|
|
432
|
+
"$__native_pattern" == "$pattern" && "$pattern" == */* ]]; then
|
|
433
|
+
__initial_directory="${pattern%/*}/"
|
|
434
|
+
__initial_leaf="${pattern##*/}"
|
|
435
|
+
if [[ "$__initial_leaf" == *[*?]* &&
|
|
436
|
+
"$__initial_directory" != *[*?]* &&
|
|
437
|
+
"$__initial_directory" != *["[]()"]* &&
|
|
438
|
+
"$__initial_leaf" != *["[]()#~^|<>;&"]* &&
|
|
439
|
+
"$__initial_leaf" != *'\'* &&
|
|
440
|
+
"$__initial_leaf" != *[[:space:]]* &&
|
|
441
|
+
"$__initial_leaf" != *"'"* && "$__initial_leaf" != *'"'* ]]; then
|
|
442
|
+
__initial_file_pattern="$__initial_leaf"
|
|
443
|
+
PREFIX="$__initial_directory"
|
|
444
|
+
compstate[pattern_match]=""
|
|
445
|
+
__pattern_match_changed=1
|
|
446
|
+
fi
|
|
447
|
+
fi
|
|
72
448
|
fi
|
|
73
449
|
fi
|
|
74
450
|
|
|
@@ -80,15 +456,114 @@ function _drfed_migrate () {
|
|
|
80
456
|
ext_pattern="*.$extensions"
|
|
81
457
|
fi
|
|
82
458
|
fi
|
|
459
|
+
# _wanted/_next_label write to the named explanation parameter.
|
|
460
|
+
# Keep it local for every file directive, including directory/any.
|
|
461
|
+
local -a expl=()
|
|
83
462
|
# Use zsh's native file completion
|
|
84
463
|
case "$type" in
|
|
85
|
-
file)
|
|
86
|
-
if [[ -n "$
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
|
|
91
|
-
|
|
464
|
+
file|any)
|
|
465
|
+
if [[ "$type" == "file" || -n "$__initial_file_pattern" ]]; then
|
|
466
|
+
# Regular-file suggestions retain symlinked files; initial
|
|
467
|
+
# any globs use a non-directory qualifier instead.
|
|
468
|
+
local file_pattern="${ext_pattern:-*}(#q-.)"
|
|
469
|
+
if [[ "$__fixed_glob" == "1" ]]; then
|
|
470
|
+
file_pattern="${ext_pattern:-*}(#q-.e:__optique-fixed-glob-64726665642d6d696772617465:)"
|
|
471
|
+
fi
|
|
472
|
+
if [[ -n "$__initial_file_pattern" ]]; then
|
|
473
|
+
local __file_qualifier="-."
|
|
474
|
+
[[ "$type" == "any" ]] && __file_qualifier="^-/"
|
|
475
|
+
local -a __initial_file_patterns=()
|
|
476
|
+
if [[ -n "$extensions" ]]; then
|
|
477
|
+
setopt extended_glob
|
|
478
|
+
local __initial_extension
|
|
479
|
+
for __initial_extension in "${(@s:,:)extensions}"; do
|
|
480
|
+
__initial_file_patterns+=("(${__initial_file_pattern}~^*.${__initial_extension})(#q${__file_qualifier})")
|
|
481
|
+
done
|
|
482
|
+
else
|
|
483
|
+
__initial_file_patterns=("${__initial_file_pattern}(#q${__file_qualifier})")
|
|
484
|
+
fi
|
|
485
|
+
file_pattern="${(j: :)__initial_file_patterns}"
|
|
486
|
+
fi
|
|
487
|
+
local file_pattern_prefix="$PREFIX"
|
|
488
|
+
local -a match mbegin mend
|
|
489
|
+
# Native qualifier copying concatenates flags with the explicit
|
|
490
|
+
# regular-file group. Keep backend attributes in their own group.
|
|
491
|
+
if [[ -n "$compstate[pattern_match]" && -z "$SUFFIX" ]]; then
|
|
492
|
+
local file_qualifier file_qualifiers=""
|
|
493
|
+
while _have_glob_qual "$file_pattern_prefix" complete; do
|
|
494
|
+
file_qualifier="${match[5]#\#q}"
|
|
495
|
+
file_pattern_prefix="$match[2]"
|
|
496
|
+
file_qualifiers="(#q$file_qualifier)$file_qualifiers"
|
|
497
|
+
done
|
|
498
|
+
if [[ -n "$file_qualifiers" ]]; then
|
|
499
|
+
file_pattern+="$file_qualifiers"
|
|
500
|
+
fi
|
|
501
|
+
fi
|
|
502
|
+
local file_subtree_pattern="**/*(#q/N)"
|
|
503
|
+
local -a file_subtree=() file_recursive_patterns=()
|
|
504
|
+
local -a file_tags=(files directories)
|
|
505
|
+
local file_recursive_pattern file_directory file_prefix file_tag
|
|
506
|
+
if [[ -n "$__initial_file_pattern" || -z "$ext_pattern" ]] &&
|
|
507
|
+
zstyle -t ":completion:${curcontext}:" list-dirs-first; then
|
|
508
|
+
file_tags=(directories files)
|
|
509
|
+
fi
|
|
510
|
+
_tags "${file_tags[@]}"
|
|
511
|
+
while _tags; do
|
|
512
|
+
local file_matched=0
|
|
513
|
+
for file_tag in "${file_tags[@]}"; do
|
|
514
|
+
if [[ "$file_tag" == directories ]]; then
|
|
515
|
+
local file_tag_prefix="$PREFIX"
|
|
516
|
+
PREFIX="$file_pattern_prefix"
|
|
517
|
+
while _next_label directories expl directory; do
|
|
518
|
+
# File qualifiers constrain final results, not the
|
|
519
|
+
# directories needed to navigate to those results.
|
|
520
|
+
_path_files -/ "${expl[@]}" && file_matched=1
|
|
521
|
+
done
|
|
522
|
+
PREFIX="$file_tag_prefix"
|
|
523
|
+
else
|
|
524
|
+
local file_tag_prefix="$PREFIX"
|
|
525
|
+
PREFIX="$file_pattern_prefix"
|
|
526
|
+
while _next_label files expl file; do
|
|
527
|
+
local -a file_ignore=() file_ignore_args=()
|
|
528
|
+
# Explicit globs bypass automatic fignore. Apply it only
|
|
529
|
+
# when the tag has not supplied its own ignore patterns.
|
|
530
|
+
if [[ -z "$__initial_file_pattern" && -z "$ext_pattern" && ( "$__fixed_glob" != "1" || "$pattern" == "*" ) && -z "$_comp_no_ignore" && -n "$FIGNORE" ]] && (( ${#_comp_ignore[@]} == 0 )); then
|
|
531
|
+
file_ignore=("?*${^fignore[@]}")
|
|
532
|
+
file_ignore_args=(-F file_ignore)
|
|
533
|
+
fi
|
|
534
|
+
if _path_files -g "${file_pattern}" "${expl[@]}" "${file_ignore_args[@]}"; then
|
|
535
|
+
file_matched=1
|
|
536
|
+
elif [[ ( -n "$__initial_file_pattern" || -z "$ext_pattern" ) && "$PREFIX$SUFFIX" != */* ]] &&
|
|
537
|
+
zstyle -a ":completion:${curcontext}:files" recursive-files file_recursive_patterns; then
|
|
538
|
+
# Match _files' recursive fallback, retaining the same
|
|
539
|
+
# file filter and tag-specific ignore options.
|
|
540
|
+
for file_recursive_pattern in "${file_recursive_patterns[@]}"; do
|
|
541
|
+
if [[ "$PWD/" = ${~file_recursive_pattern} ]]; then
|
|
542
|
+
if (( ${#file_subtree[@]} == 0 )); then
|
|
543
|
+
file_subtree=(${~file_subtree_pattern})
|
|
544
|
+
fi
|
|
545
|
+
for file_directory in "${file_subtree[@]}"; do
|
|
546
|
+
file_prefix="$PREFIX"
|
|
547
|
+
PREFIX="$file_directory/$PREFIX"
|
|
548
|
+
_path_files -g "${file_pattern}" "${expl[@]}" "${file_ignore_args[@]}" && file_matched=1
|
|
549
|
+
PREFIX="$file_prefix"
|
|
550
|
+
done
|
|
551
|
+
break
|
|
552
|
+
fi
|
|
553
|
+
done
|
|
554
|
+
fi
|
|
555
|
+
done
|
|
556
|
+
PREFIX="$file_tag_prefix"
|
|
557
|
+
fi
|
|
558
|
+
done
|
|
559
|
+
(( file_matched )) && break
|
|
560
|
+
done
|
|
561
|
+
elif [[ -n "$ext_pattern" || "$__fixed_glob" == "1" ]]; then
|
|
562
|
+
local file_pattern="${ext_pattern}(#q^-/)"
|
|
563
|
+
if [[ "$__fixed_glob" == "1" ]]; then
|
|
564
|
+
# Put the predicate before ^, which negates later qualifiers.
|
|
565
|
+
file_pattern="${ext_pattern:-*}(#qe:__optique-fixed-glob-64726665642d6d696772617465:^-/)"
|
|
566
|
+
fi
|
|
92
567
|
_wanted files expl file _path_files -g "${file_pattern}"
|
|
93
568
|
_wanted directories expl directory _path_files -/
|
|
94
569
|
else
|
|
@@ -96,22 +571,25 @@ function _drfed_migrate () {
|
|
|
96
571
|
fi
|
|
97
572
|
;;
|
|
98
573
|
directory)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if [[ -n "$ext_pattern" ]]; then
|
|
103
|
-
local file_pattern="${ext_pattern}(#q^-/)"
|
|
104
|
-
_wanted files expl file _path_files -g "${file_pattern}"
|
|
105
|
-
_wanted directories expl directory _path_files -/
|
|
574
|
+
if [[ -n "$__initial_file_pattern" ]]; then
|
|
575
|
+
# -/ would add every directory alongside the filtered glob.
|
|
576
|
+
_wanted directories expl directory _path_files -g "${__initial_file_pattern}(#q-/)"
|
|
106
577
|
else
|
|
107
|
-
|
|
578
|
+
_directories
|
|
108
579
|
fi
|
|
109
580
|
;;
|
|
110
581
|
esac
|
|
111
|
-
|
|
112
582
|
# Restore PREFIX and glob_dots to their previous state
|
|
113
583
|
PREFIX="$__saved_prefix"
|
|
584
|
+
IPREFIX="$__saved_iprefix"
|
|
585
|
+
current="$__saved_current"
|
|
586
|
+
__logical_prefix="$__saved_logical_prefix"
|
|
587
|
+
if [[ "$__was_extended_glob" == "1" ]]; then setopt extended_glob; else unsetopt extended_glob; fi
|
|
588
|
+
if (( __pattern_match_changed )); then
|
|
589
|
+
compstate[pattern_match]="$__saved_pattern_match"
|
|
590
|
+
fi
|
|
114
591
|
if [[ "$__was_sh_glob" == "1" ]]; then setopt sh_glob; else unsetopt sh_glob; fi
|
|
592
|
+
if [[ "$__was_sh_word_split" == "1" ]]; then setopt sh_word_split; else unsetopt sh_word_split; fi
|
|
115
593
|
if [[ "$__was_glob_dots" == "1" ]]; then setopt glob_dots; else unsetopt glob_dots; fi
|
|
116
594
|
else
|
|
117
595
|
# Regular literal completion
|
|
@@ -128,18 +606,38 @@ function _drfed_migrate () {
|
|
|
128
606
|
# Prepare completion with descriptions for _describe
|
|
129
607
|
local -a matches
|
|
130
608
|
local -i i
|
|
609
|
+
local __match
|
|
131
610
|
for (( i=1; i <= ${#completions[@]}; i++ )); do
|
|
611
|
+
# _describe uses backslashes to escape its colon separator.
|
|
612
|
+
__match="${completions[i]//\\/\\\\}"
|
|
613
|
+
__match="${__match//:/\\:}"
|
|
132
614
|
if [[ -n "${descriptions[i]}" ]]; then
|
|
133
|
-
matches+=("$
|
|
615
|
+
matches+=("$__match:${descriptions[i]}")
|
|
134
616
|
else
|
|
135
|
-
matches+=("$
|
|
617
|
+
matches+=("$__match")
|
|
136
618
|
fi
|
|
137
619
|
done
|
|
138
|
-
|
|
620
|
+
if [[ -n "$QISUFFIX" ]]; then
|
|
621
|
+
# A closing quote already exists; do not append a space inside it.
|
|
622
|
+
_describe 'commands' matches -S ''
|
|
623
|
+
else
|
|
624
|
+
_describe 'commands' matches
|
|
625
|
+
fi
|
|
139
626
|
fi
|
|
140
627
|
}
|
|
141
628
|
|
|
629
|
+
function __optique-fixed-glob-64726665642d6d696772617465 () {
|
|
630
|
+
local __fixed_candidate="${REPLY:a}"
|
|
631
|
+
(( ${__fixed_matches[(Ie)$__fixed_candidate]} ))
|
|
632
|
+
}
|
|
633
|
+
|
|
142
634
|
if (( $+functions[compdef] )); then
|
|
143
|
-
compdef
|
|
635
|
+
compdef _optique:drfed-migrate drfed-migrate
|
|
636
|
+
fi
|
|
637
|
+
|
|
638
|
+
# An autoloaded file runs as a function body. Dispatch its initial request;
|
|
639
|
+
# sourcing the file only defines and registers the completion helper.
|
|
640
|
+
if [[ $ZSH_EVAL_CONTEXT == *:loadautofunc || $ZSH_EVAL_CONTEXT == *:shfunc ]]; then
|
|
641
|
+
_optique:drfed-migrate "$@"
|
|
144
642
|
fi
|
|
145
643
|
|