@shell-shock/plugin-completions 0.2.22 → 0.2.24
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/README.md +1 -1
- package/dist/components/bash-command.cjs +21 -18
- package/dist/components/bash-command.mjs +23 -20
- package/dist/components/bash-command.mjs.map +1 -1
- package/dist/components/fish-command.cjs +80 -76
- package/dist/components/fish-command.mjs +82 -78
- package/dist/components/fish-command.mjs.map +1 -1
- package/dist/components/powershell-command.cjs +45 -39
- package/dist/components/powershell-command.d.cts.map +1 -1
- package/dist/components/powershell-command.d.mts.map +1 -1
- package/dist/components/powershell-command.mjs +47 -41
- package/dist/components/powershell-command.mjs.map +1 -1
- package/dist/components/zsh-command.cjs +80 -77
- package/dist/components/zsh-command.mjs +82 -79
- package/dist/components/zsh-command.mjs.map +1 -1
- package/dist/helpers/complete-command.cjs +2 -7
- package/dist/helpers/complete-command.d.cts +2 -2
- package/dist/helpers/complete-command.d.cts.map +1 -1
- package/dist/helpers/complete-command.d.mts +2 -2
- package/dist/helpers/complete-command.d.mts.map +1 -1
- package/dist/helpers/complete-command.mjs +2 -7
- package/dist/helpers/complete-command.mjs.map +1 -1
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers/index.d.cts +2 -2
- package/dist/helpers/index.d.mts +2 -2
- package/dist/helpers/index.mjs +2 -2
- package/dist/index.cjs +37 -15
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +38 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -4
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EXEC_COMMAND } from "../helpers/complete-command.mjs";
|
|
2
2
|
import { CompletionDirective } from "../helpers/completion-directive-constants.mjs";
|
|
3
3
|
import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
|
|
4
4
|
import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
5
|
-
import {
|
|
6
|
-
import { code } from "@alloy-js/core";
|
|
5
|
+
import { code, computed } from "@alloy-js/core";
|
|
7
6
|
import { FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
8
7
|
import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
9
8
|
import { Spacing } from "@powerlines/plugin-alloy/core";
|
|
10
9
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
11
10
|
import { InterfaceMember, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
|
|
12
11
|
import { TSDoc, TSDocDefaultValue, TSDocRemarks } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
12
|
+
import { joinPaths } from "@stryke/path";
|
|
13
13
|
import { snakeCase } from "@stryke/string-format/snake-case";
|
|
14
14
|
|
|
15
15
|
//#region src/components/fish-command.tsx
|
|
@@ -18,12 +18,15 @@ import { snakeCase } from "@stryke/string-format/snake-case";
|
|
|
18
18
|
*/
|
|
19
19
|
function FishCompletionsCommand() {
|
|
20
20
|
const context = usePowerlines();
|
|
21
|
+
const bin = computed(() => getAppBin(context));
|
|
22
|
+
const name = computed(() => snakeCase(bin.value));
|
|
21
23
|
return createComponent(TypescriptFile, {
|
|
22
24
|
get path() {
|
|
23
25
|
return joinPaths(context.entryPath, "completions", "fish", "command.ts");
|
|
24
26
|
},
|
|
25
27
|
imports: {
|
|
26
|
-
"node:os":
|
|
28
|
+
"node:os": "os",
|
|
29
|
+
"node:path": ["join"],
|
|
27
30
|
"node:fs/promises": ["readFile", "writeFile"]
|
|
28
31
|
},
|
|
29
32
|
builtinImports: { "shell-shock:console": [
|
|
@@ -49,7 +52,7 @@ function FishCompletionsCommand() {
|
|
|
49
52
|
return ReflectionKind.string;
|
|
50
53
|
},
|
|
51
54
|
get defaultValue() {
|
|
52
|
-
return `${
|
|
55
|
+
return `${bin.value}-completions.fish`;
|
|
53
56
|
}
|
|
54
57
|
})];
|
|
55
58
|
}
|
|
@@ -97,30 +100,30 @@ function FishCompletionsCommand() {
|
|
|
97
100
|
name: "completions",
|
|
98
101
|
type: "string",
|
|
99
102
|
get initializer() {
|
|
100
|
-
return code
|
|
103
|
+
return code` \`# fish completion for ${getAppTitle(context)} -*- shell-script -*-
|
|
101
104
|
|
|
102
|
-
function __${
|
|
105
|
+
function __${name.value}_debug
|
|
103
106
|
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
104
107
|
if test -n "$file"
|
|
105
108
|
echo "$argv" >> $file
|
|
106
109
|
end
|
|
107
110
|
end
|
|
108
111
|
|
|
109
|
-
function __${
|
|
110
|
-
__${
|
|
112
|
+
function __${name.value}_perform_completion
|
|
113
|
+
__${name.value}_debug "Starting __${name.value}_perform_completion"
|
|
111
114
|
|
|
112
115
|
# Extract all args except the last one
|
|
113
116
|
set -l args (commandline -opc)
|
|
114
117
|
# Extract the last arg and escape it in case it is a space or wildcard
|
|
115
118
|
set -l lastArg (string escape -- (commandline -ct))
|
|
116
119
|
|
|
117
|
-
__${
|
|
118
|
-
__${
|
|
120
|
+
__${name.value}_debug "args: $args"
|
|
121
|
+
__${name.value}_debug "last arg: $lastArg"
|
|
119
122
|
|
|
120
123
|
# Build the completion request command
|
|
121
|
-
set -l requestComp "${
|
|
124
|
+
set -l requestComp "${EXEC_COMMAND} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
|
|
122
125
|
|
|
123
|
-
__${
|
|
126
|
+
__${name.value}_debug "Calling $requestComp"
|
|
124
127
|
set -l results (eval $requestComp 2> /dev/null)
|
|
125
128
|
|
|
126
129
|
# Some programs may output extra empty lines after the directive.
|
|
@@ -143,9 +146,9 @@ function __${snakeCase(getAppBin(context))}_perform_completion
|
|
|
143
146
|
# completions must be prefixed with the flag
|
|
144
147
|
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
|
|
145
148
|
|
|
146
|
-
__${
|
|
147
|
-
__${
|
|
148
|
-
__${
|
|
149
|
+
__${name.value}_debug "Comps: $comps"
|
|
150
|
+
__${name.value}_debug "DirectiveLine: $directiveLine"
|
|
151
|
+
__${name.value}_debug "flagPrefix: $flagPrefix"
|
|
149
152
|
|
|
150
153
|
for comp in $comps
|
|
151
154
|
printf "%s%s\\n" "$flagPrefix" "$comp"
|
|
@@ -154,83 +157,84 @@ function __${snakeCase(getAppBin(context))}_perform_completion
|
|
|
154
157
|
printf "%s\\n" "$directiveLine"
|
|
155
158
|
end
|
|
156
159
|
|
|
157
|
-
# This function limits calls to __${
|
|
158
|
-
function __${
|
|
159
|
-
__${
|
|
160
|
+
# This function limits calls to __${name.value}_perform_completion, by caching the result
|
|
161
|
+
function __${name.value}_perform_completion_once
|
|
162
|
+
__${name.value}_debug "Starting __${name.value}_perform_completion_once"
|
|
160
163
|
|
|
161
|
-
if test -n "$__${
|
|
162
|
-
__${
|
|
164
|
+
if test -n "$__${name.value}_perform_completion_once_result"
|
|
165
|
+
__${name.value}_debug "Seems like a valid result already exists, skipping __${name.value}_perform_completion"
|
|
163
166
|
return 0
|
|
164
167
|
end
|
|
165
168
|
|
|
166
|
-
set --global __${
|
|
167
|
-
if test -z "$__${
|
|
168
|
-
__${
|
|
169
|
+
set --global __${name.value}_perform_completion_once_result (__${name.value}_perform_completion)
|
|
170
|
+
if test -z "$__${name.value}_perform_completion_once_result"
|
|
171
|
+
__${name.value}_debug "No completions, probably due to a failure"
|
|
169
172
|
return 1
|
|
170
173
|
end
|
|
171
174
|
|
|
172
|
-
__${
|
|
175
|
+
__${name.value}_debug "Performed completions and set __${name.value}_perform_completion_once_result"
|
|
173
176
|
return 0
|
|
174
177
|
end
|
|
175
178
|
|
|
176
179
|
# This function is used to clear the cached result after completions are run
|
|
177
|
-
function __${
|
|
178
|
-
__${
|
|
179
|
-
__${
|
|
180
|
-
set --erase __${
|
|
181
|
-
__${
|
|
180
|
+
function __${name.value}_clear_perform_completion_once_result
|
|
181
|
+
__${name.value}_debug ""
|
|
182
|
+
__${name.value}_debug "========= clearing previously set __${name.value}_perform_completion_once_result variable =========="
|
|
183
|
+
set --erase __${name.value}_perform_completion_once_result
|
|
184
|
+
__${name.value}_debug "Successfully erased the variable __${name.value}_perform_completion_once_result"
|
|
182
185
|
end
|
|
183
186
|
|
|
184
|
-
function __${
|
|
185
|
-
__${
|
|
186
|
-
__${
|
|
187
|
+
function __${name.value}_requires_order_preservation
|
|
188
|
+
__${name.value}_debug ""
|
|
189
|
+
__${name.value}_debug "========= checking if order preservation is required =========="
|
|
187
190
|
|
|
188
|
-
__${
|
|
189
|
-
if test -z "$__${
|
|
190
|
-
__${
|
|
191
|
+
__${name.value}_perform_completion_once
|
|
192
|
+
if test -z "$__${name.value}_perform_completion_once_result"
|
|
193
|
+
__${name.value}_debug "Error determining if order preservation is required"
|
|
191
194
|
return 1
|
|
192
195
|
end
|
|
193
196
|
|
|
194
|
-
set -l directive (string sub --start 2 $__$
|
|
195
|
-
|
|
197
|
+
set -l directive (string sub --start 2 $__$
|
|
198
|
+
{name.value}_perform_completion_once_result[-1])
|
|
199
|
+
__${name.value}_debug "Directive is: $directive"
|
|
196
200
|
|
|
197
201
|
set -l shellCompDirectiveKeepOrder ${CompletionDirective.CompletionDirectiveKeepOrder}
|
|
198
202
|
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
|
|
199
|
-
__${
|
|
203
|
+
__${name.value}_debug "Keeporder is: $keeporder"
|
|
200
204
|
|
|
201
205
|
if test $keeporder -ne 0
|
|
202
|
-
__${
|
|
206
|
+
__${name.value}_debug "This does require order preservation"
|
|
203
207
|
return 0
|
|
204
208
|
end
|
|
205
209
|
|
|
206
|
-
__${
|
|
210
|
+
__${name.value}_debug "This doesn't require order preservation"
|
|
207
211
|
return 1
|
|
208
212
|
end
|
|
209
213
|
|
|
210
214
|
# This function does two things:
|
|
211
|
-
# - Obtain the completions and store them in the global __${
|
|
215
|
+
# - Obtain the completions and store them in the global __${name.value}_comp_results
|
|
212
216
|
# - Return false if file completion should be performed
|
|
213
|
-
function __${
|
|
214
|
-
__${
|
|
215
|
-
__${
|
|
217
|
+
function __${name.value}_prepare_completions
|
|
218
|
+
__${name.value}_debug ""
|
|
219
|
+
__${name.value}_debug "========= starting completion logic =========="
|
|
216
220
|
|
|
217
221
|
# Start fresh
|
|
218
|
-
set --erase __${
|
|
222
|
+
set --erase __${name.value}_comp_results
|
|
219
223
|
|
|
220
|
-
__${
|
|
221
|
-
__${
|
|
224
|
+
__${name.value}_perform_completion_once
|
|
225
|
+
__${name.value}_debug "Completion results: $__${name.value}_perform_completion_once_result"
|
|
222
226
|
|
|
223
|
-
if test -z "$__${
|
|
224
|
-
__${
|
|
227
|
+
if test -z "$__${name.value}_perform_completion_once_result"
|
|
228
|
+
__${name.value}_debug "No completion, probably due to a failure"
|
|
225
229
|
# Might as well do file completion, in case it helps
|
|
226
230
|
return 1
|
|
227
231
|
end
|
|
228
232
|
|
|
229
|
-
set -l directive (string sub --start 2 $__${
|
|
230
|
-
set --global __${
|
|
233
|
+
set -l directive (string sub --start 2 $__${name.value}_perform_completion_once_result[-1])
|
|
234
|
+
set --global __${name.value}_comp_results $__${name.value}_perform_completion_once_result[1..-2]
|
|
231
235
|
|
|
232
|
-
__${
|
|
233
|
-
__${
|
|
236
|
+
__${name.value}_debug "Completions are: $__${name.value}_comp_results"
|
|
237
|
+
__${name.value}_debug "Directive is: $directive"
|
|
234
238
|
|
|
235
239
|
set -l shellCompDirectiveError ${CompletionDirective.CompletionDirectiveError}
|
|
236
240
|
set -l shellCompDirectiveNoSpace ${CompletionDirective.CompletionDirectiveNoSpace}
|
|
@@ -243,7 +247,7 @@ function __${snakeCase(getAppBin(context))}_prepare_completions
|
|
|
243
247
|
|
|
244
248
|
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
|
|
245
249
|
if test $compErr -eq 1
|
|
246
|
-
__${
|
|
250
|
+
__${name.value}_debug "Received error directive: aborting."
|
|
247
251
|
# Might as well do file completion, in case it helps
|
|
248
252
|
return 1
|
|
249
253
|
end
|
|
@@ -251,7 +255,7 @@ function __${snakeCase(getAppBin(context))}_prepare_completions
|
|
|
251
255
|
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
|
|
252
256
|
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
|
|
253
257
|
if test $filefilter -eq 1; or test $dirfilter -eq 1
|
|
254
|
-
__${
|
|
258
|
+
__${name.value}_debug "File extension filtering or directory filtering not supported"
|
|
255
259
|
# Do full file completion instead
|
|
256
260
|
return 1
|
|
257
261
|
end
|
|
@@ -259,7 +263,7 @@ function __${snakeCase(getAppBin(context))}_prepare_completions
|
|
|
259
263
|
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
|
|
260
264
|
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
|
|
261
265
|
|
|
262
|
-
__${
|
|
266
|
+
__${name.value}_debug "nospace: $nospace, nofiles: $nofiles"
|
|
263
267
|
|
|
264
268
|
# If we want to prevent a space, or if file completion is NOT disabled,
|
|
265
269
|
# we need to count the number of valid completions.
|
|
@@ -268,22 +272,22 @@ function __${snakeCase(getAppBin(context))}_prepare_completions
|
|
|
268
272
|
# criteria than the prefix.
|
|
269
273
|
if test $nospace -ne 0; or test $nofiles -eq 0
|
|
270
274
|
set -l prefix (commandline -t | string escape --style=regex)
|
|
271
|
-
__${
|
|
275
|
+
__${name.value}_debug "prefix: $prefix"
|
|
272
276
|
|
|
273
|
-
set -l completions (string match -r -- "^$prefix.*" $__${
|
|
274
|
-
set --global __${
|
|
275
|
-
__${
|
|
277
|
+
set -l completions (string match -r -- "^$prefix.*" $__${name.value}_comp_results)
|
|
278
|
+
set --global __${name.value}_comp_results $completions
|
|
279
|
+
__${name.value}_debug "Filtered completions are: $__${name.value}_comp_results"
|
|
276
280
|
|
|
277
281
|
# Important not to quote the variable for count to work
|
|
278
|
-
set -l numComps (count $__${
|
|
279
|
-
__${
|
|
282
|
+
set -l numComps (count $__${name.value}_comp_results)
|
|
283
|
+
__${name.value}_debug "numComps: $numComps"
|
|
280
284
|
|
|
281
285
|
if test $numComps -eq 1; and test $nospace -ne 0
|
|
282
286
|
# We must first split on \\t to get rid of the descriptions to be
|
|
283
287
|
# able to check what the actual completion will be.
|
|
284
288
|
# We don't need descriptions anyway since there is only a single
|
|
285
289
|
# real completion which the shell will expand immediately.
|
|
286
|
-
set -l split (string split --max 1 "\\t" $__${
|
|
290
|
+
set -l split (string split --max 1 "\\t" $__${name.value}_comp_results[1])
|
|
287
291
|
|
|
288
292
|
# Fish won't add a space if the completion ends with any
|
|
289
293
|
# of the following characters: @=/:.,
|
|
@@ -291,16 +295,16 @@ function __${snakeCase(getAppBin(context))}_prepare_completions
|
|
|
291
295
|
if not string match -r -q "[@=/:.,]" -- "$lastChar"
|
|
292
296
|
# In other cases, to support the "nospace" directive we trick the shell
|
|
293
297
|
# by outputting an extra, longer completion.
|
|
294
|
-
__${
|
|
295
|
-
set --global __${
|
|
296
|
-
__${
|
|
298
|
+
__${name.value}_debug "Adding second completion to perform nospace directive"
|
|
299
|
+
set --global __${name.value}_comp_results $split[1] $split[1].
|
|
300
|
+
__${name.value}_debug "Completions are now: $__${name.value}_comp_results"
|
|
297
301
|
end
|
|
298
302
|
end
|
|
299
303
|
|
|
300
304
|
if test $numComps -eq 0; and test $nofiles -eq 0
|
|
301
305
|
# To be consistent with bash and zsh, we only trigger file
|
|
302
306
|
# completion when there are no other completions
|
|
303
|
-
__${
|
|
307
|
+
__${name.value}_debug "Requesting file completion"
|
|
304
308
|
return 1
|
|
305
309
|
end
|
|
306
310
|
end
|
|
@@ -312,24 +316,24 @@ end
|
|
|
312
316
|
# so we can properly delete any completions provided by another script.
|
|
313
317
|
# Only do this if the program can be found, or else fish may print some errors; besides,
|
|
314
318
|
# the existing completions will only be loaded if the program can be found.
|
|
315
|
-
if type -q "${
|
|
319
|
+
if type -q "${bin.value}"
|
|
316
320
|
# The space after the program name is essential to trigger completion for the program
|
|
317
321
|
# and not completion of the program name itself.
|
|
318
322
|
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
|
|
319
|
-
complete --do-complete "${
|
|
323
|
+
complete --do-complete "${bin.value} " > /dev/null 2>&1
|
|
320
324
|
end
|
|
321
325
|
|
|
322
326
|
# Remove any pre-existing completions for the program since we will be handling all of them.
|
|
323
|
-
complete -c ${
|
|
327
|
+
complete -c ${bin.value} -e
|
|
324
328
|
# This will get called after the two calls below and clear the cached result
|
|
325
|
-
complete -c ${
|
|
326
|
-
# The call to __${
|
|
329
|
+
complete -c ${bin.value} -n '__${name.value}_clear_perform_completion_once_result'
|
|
330
|
+
# The call to __${name.value}_prepare_completions will setup __${name.value}_comp_results
|
|
327
331
|
# which provides the program's completion choices.
|
|
328
332
|
# If this doesn't require order preservation, we don't use the -k flag
|
|
329
|
-
complete -c ${getAppBin(context)} -n 'not __${
|
|
333
|
+
complete -c ${getAppBin(context)} -n 'not __${name.value}_requires_order_preservation && __${name.value}_prepare_completions' -f -a '$__${name.value}_comp_results'
|
|
330
334
|
# Otherwise we use the -k flag
|
|
331
|
-
complete -k -c ${
|
|
332
|
-
|
|
335
|
+
complete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && __${name.value}_prepare_completions' -f -a '$__${name.value}_comp_results'
|
|
336
|
+
\`; `;
|
|
333
337
|
}
|
|
334
338
|
}),
|
|
335
339
|
createComponent(Spacing, {}),
|
|
@@ -359,7 +363,7 @@ complete -k -c ${getAppBin(context)} -n '__${snakeCase(getAppBin(context))}_requ
|
|
|
359
363
|
memo(() => code`try {
|
|
360
364
|
configFileContent = await readFile(configFilePath, "utf8");
|
|
361
365
|
} catch (error) {
|
|
362
|
-
if (error.code === "ENOENT") {
|
|
366
|
+
if (Error.isError(error) && error.code === "ENOENT") {
|
|
363
367
|
// If the file doesn't exist, we can create it later when writing the completion script.
|
|
364
368
|
warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
|
|
365
369
|
} else {
|
|
@@ -377,7 +381,7 @@ complete -k -c ${getAppBin(context)} -n '__${snakeCase(getAppBin(context))}_requ
|
|
|
377
381
|
createComponent(IfStatement, {
|
|
378
382
|
condition: code`options.script`,
|
|
379
383
|
get children() {
|
|
380
|
-
return code`const outputPath = options.script === true ? "${
|
|
384
|
+
return code`const outputPath = options.script === true ? "${bin.value}-completions.fish" : options.script;
|
|
381
385
|
await writeFile(outputPath, stripAnsi(completions));
|
|
382
386
|
|
|
383
387
|
success(\`${getAppTitle(context)} Fish completion script has been generated at \${colors.bold(outputPath)}.\`);`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fish-command.mjs","names":[],"sources":["../../src/components/fish-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue,\n TSDocRemarks\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { exec } from \"../helpers/complete-command\";\nimport { CompletionDirective } from \"../helpers/completion-directive-constants\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions commands' handler wrapper for the Shell Shock project.\n */\nexport function FishCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(context.entryPath, \"completions\", \"fish\", \"command.ts\")}\n imports={{\n \"node:os\": [\"os\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"]\n }}\n builtinImports={{\n \"shell-shock:console\": [\n \"colors\",\n \"writeLine\",\n \"success\",\n \"warn\",\n \"stripAnsi\"\n ]\n }}>\n <TSDoc heading=\"Options for the Fish completions command.\" />\n <InterfaceDeclaration export name=\"FishCompletionsOptions\">\n <TSDoc heading=\"The path to write the completion script to.\">\n <TSDocRemarks>{`If no extension is provided, the \\`.fish\\` extension will be used.`}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue={`${getAppBin(context)}-completions.fish`}\n />\n </TSDoc>\n <InterfaceMember name=\"script\" optional type=\"string | true\" />\n <Spacing />\n <TSDoc heading=\"The Fish configuration file to append the completion script to.\">\n <TSDocRemarks>{`The generated completion script will be appended to the specified configuration file. Possible values for the Fish configuration file include: \\\\n- \\`~/.config/fish/config.fish\\``}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue=\"~/.config/fish/config.fish\"\n />\n </TSDoc>\n <InterfaceMember name=\"config\" optional type=\"string | true\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions fish\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[{ name: \"options\", type: \"FishCompletionsOptions\" }]}>\n <VarDeclaration\n const\n name=\"completions\"\n type=\"string\"\n initializer={code`# fish completion for ${getAppTitle(\n context\n )} -*- shell-script -*-\n\nfunction __${snakeCase(getAppBin(context))}_debug\n set -l file \"$BASH_COMP_DEBUG_FILE\"\n if test -n \"$file\"\n echo \"$argv\" >> $file\n end\nend\n\nfunction __${snakeCase(getAppBin(context))}_perform_completion\n __${snakeCase(getAppBin(context))}_debug \"Starting __${snakeCase(getAppBin(context))}_perform_completion\"\n\n # Extract all args except the last one\n set -l args (commandline -opc)\n # Extract the last arg and escape it in case it is a space or wildcard\n set -l lastArg (string escape -- (commandline -ct))\n\n __${snakeCase(getAppBin(context))}_debug \"args: $args\"\n __${snakeCase(getAppBin(context))}_debug \"last arg: $lastArg\"\n\n # Build the completion request command\n set -l requestComp \"${exec} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg\"\n\n __${snakeCase(getAppBin(context))}_debug \"Calling $requestComp\"\n set -l results (eval $requestComp 2> /dev/null)\n\n # Some programs may output extra empty lines after the directive.\n # Let's ignore them or else it will break completion.\n # Ref: https://github.com/spf13/cobra/issues/1279\n for line in $results[-1..1]\n if test (string trim -- $line) = \"\"\n # Found an empty line, remove it\n set results $results[1..-2]\n else\n # Found non-empty line, we have our proper output\n break\n end\n end\n\n set -l comps $results[1..-2]\n set -l directiveLine $results[-1]\n\n # For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)\n # completions must be prefixed with the flag\n set -l flagPrefix (string match -r -- '-.*=' \"$lastArg\")\n\n __${snakeCase(getAppBin(context))}_debug \"Comps: $comps\"\n __${snakeCase(getAppBin(context))}_debug \"DirectiveLine: $directiveLine\"\n __${snakeCase(getAppBin(context))}_debug \"flagPrefix: $flagPrefix\"\n\n for comp in $comps\n printf \"%s%s\\\\n\" \"$flagPrefix\" \"$comp\"\n end\n\n printf \"%s\\\\n\" \"$directiveLine\"\nend\n\n# This function limits calls to __${snakeCase(getAppBin(context))}_perform_completion, by caching the result\nfunction __${snakeCase(getAppBin(context))}_perform_completion_once\n __${snakeCase(getAppBin(context))}_debug \"Starting __${snakeCase(\n getAppBin(context)\n )}_perform_completion_once\"\n\n if test -n \"$__${snakeCase(getAppBin(context))}_perform_completion_once_result\"\n __${snakeCase(getAppBin(context))}_debug \"Seems like a valid result already exists, skipping __${snakeCase(getAppBin(context))}_perform_completion\"\n return 0\n end\n\n set --global __${snakeCase(getAppBin(context))}_perform_completion_once_result (__${snakeCase(getAppBin(context))}_perform_completion)\n if test -z \"$__${snakeCase(getAppBin(context))}_perform_completion_once_result\"\n __${snakeCase(getAppBin(context))}_debug \"No completions, probably due to a failure\"\n return 1\n end\n\n __${snakeCase(getAppBin(context))}_debug \"Performed completions and set __${snakeCase(getAppBin(context))}_perform_completion_once_result\"\n return 0\nend\n\n# This function is used to clear the cached result after completions are run\nfunction __${snakeCase(getAppBin(context))}_clear_perform_completion_once_result\n __${snakeCase(getAppBin(context))}_debug \"\"\n __${snakeCase(getAppBin(context))}_debug \"========= clearing previously set __${snakeCase(getAppBin(context))}_perform_completion_once_result variable ==========\"\n set --erase __${snakeCase(getAppBin(context))}_perform_completion_once_result\n __${snakeCase(getAppBin(context))}_debug \"Successfully erased the variable __${snakeCase(getAppBin(context))}_perform_completion_once_result\"\nend\n\nfunction __${snakeCase(getAppBin(context))}_requires_order_preservation\n __${snakeCase(getAppBin(context))}_debug \"\"\n __${snakeCase(getAppBin(context))}_debug \"========= checking if order preservation is required ==========\"\n\n __${snakeCase(getAppBin(context))}_perform_completion_once\n if test -z \"$__${snakeCase(getAppBin(context))}_perform_completion_once_result\"\n __${snakeCase(getAppBin(context))}_debug \"Error determining if order preservation is required\"\n return 1\n end\n\n set -l directive (string sub --start 2 $__${snakeCase(\n getAppBin(context)\n )}_perform_completion_once_result[-1])\n __${snakeCase(getAppBin(context))}_debug \"Directive is: $directive\"\n\n set -l shellCompDirectiveKeepOrder ${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)\n __${snakeCase(getAppBin(context))}_debug \"Keeporder is: $keeporder\"\n\n if test $keeporder -ne 0\n __${snakeCase(getAppBin(context))}_debug \"This does require order preservation\"\n return 0\n end\n\n __${snakeCase(getAppBin(context))}_debug \"This doesn't require order preservation\"\n return 1\nend\n\n# This function does two things:\n# - Obtain the completions and store them in the global __${snakeCase(getAppBin(context))}_comp_results\n# - Return false if file completion should be performed\nfunction __${snakeCase(getAppBin(context))}_prepare_completions\n __${snakeCase(getAppBin(context))}_debug \"\"\n __${snakeCase(getAppBin(context))}_debug \"========= starting completion logic ==========\"\n\n # Start fresh\n set --erase __${snakeCase(getAppBin(context))}_comp_results\n\n __${snakeCase(getAppBin(context))}_perform_completion_once\n __${snakeCase(getAppBin(context))}_debug \"Completion results: $__${snakeCase(getAppBin(context))}_perform_completion_once_result\"\n\n if test -z \"$__${snakeCase(getAppBin(context))}_perform_completion_once_result\"\n __${snakeCase(getAppBin(context))}_debug \"No completion, probably due to a failure\"\n # Might as well do file completion, in case it helps\n return 1\n end\n\n set -l directive (string sub --start 2 $__${snakeCase(getAppBin(context))}_perform_completion_once_result[-1])\n set --global __${snakeCase(getAppBin(context))}_comp_results $__${snakeCase(getAppBin(context))}_perform_completion_once_result[1..-2]\n\n __${snakeCase(getAppBin(context))}_debug \"Completions are: $__${snakeCase(getAppBin(context))}_comp_results\"\n __${snakeCase(getAppBin(context))}_debug \"Directive is: $directive\"\n\n set -l shellCompDirectiveError ${\n CompletionDirective.CompletionDirectiveError\n }\n set -l shellCompDirectiveNoSpace ${\n CompletionDirective.CompletionDirectiveNoSpace\n }\n set -l shellCompDirectiveNoFileComp ${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\n set -l shellCompDirectiveFilterFileExt ${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\n set -l shellCompDirectiveFilterDirs ${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\n if test -z \"$directive\"\n set directive 0\n end\n\n set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)\n if test $compErr -eq 1\n __${snakeCase(getAppBin(context))}_debug \"Received error directive: aborting.\"\n # Might as well do file completion, in case it helps\n return 1\n end\n\n set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)\n set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)\n if test $filefilter -eq 1; or test $dirfilter -eq 1\n __${snakeCase(getAppBin(context))}_debug \"File extension filtering or directory filtering not supported\"\n # Do full file completion instead\n return 1\n end\n\n set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)\n set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)\n\n __${snakeCase(getAppBin(context))}_debug \"nospace: $nospace, nofiles: $nofiles\"\n\n # If we want to prevent a space, or if file completion is NOT disabled,\n # we need to count the number of valid completions.\n # To do so, we will filter on prefix as the completions we have received\n # may not already be filtered so as to allow fish to match on different\n # criteria than the prefix.\n if test $nospace -ne 0; or test $nofiles -eq 0\n set -l prefix (commandline -t | string escape --style=regex)\n __${snakeCase(getAppBin(context))}_debug \"prefix: $prefix\"\n\n set -l completions (string match -r -- \"^$prefix.*\" $__${snakeCase(getAppBin(context))}_comp_results)\n set --global __${snakeCase(getAppBin(context))}_comp_results $completions\n __${snakeCase(getAppBin(context))}_debug \"Filtered completions are: $__${snakeCase(getAppBin(context))}_comp_results\"\n\n # Important not to quote the variable for count to work\n set -l numComps (count $__${snakeCase(getAppBin(context))}_comp_results)\n __${snakeCase(getAppBin(context))}_debug \"numComps: $numComps\"\n\n if test $numComps -eq 1; and test $nospace -ne 0\n # We must first split on \\\\t to get rid of the descriptions to be\n # able to check what the actual completion will be.\n # We don't need descriptions anyway since there is only a single\n # real completion which the shell will expand immediately.\n set -l split (string split --max 1 \"\\\\t\" $__${snakeCase(getAppBin(context))}_comp_results[1])\n\n # Fish won't add a space if the completion ends with any\n # of the following characters: @=/:.,\n set -l lastChar (string sub -s -1 -- $split)\n if not string match -r -q \"[@=/:.,]\" -- \"$lastChar\"\n # In other cases, to support the \"nospace\" directive we trick the shell\n # by outputting an extra, longer completion.\n __${snakeCase(getAppBin(context))}_debug \"Adding second completion to perform nospace directive\"\n set --global __${snakeCase(getAppBin(context))}_comp_results $split[1] $split[1].\n __${snakeCase(getAppBin(context))}_debug \"Completions are now: $__${snakeCase(getAppBin(context))}_comp_results\"\n end\n end\n\n if test $numComps -eq 0; and test $nofiles -eq 0\n # To be consistent with bash and zsh, we only trigger file\n # completion when there are no other completions\n __${snakeCase(getAppBin(context))}_debug \"Requesting file completion\"\n return 1\n end\n end\n\n return 0\nend\n\n# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves\n# so we can properly delete any completions provided by another script.\n# Only do this if the program can be found, or else fish may print some errors; besides,\n# the existing completions will only be loaded if the program can be found.\nif type -q \"${getAppBin(context)}\"\n # The space after the program name is essential to trigger completion for the program\n # and not completion of the program name itself.\n # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.\n complete --do-complete \"${getAppBin(context)} \" > /dev/null 2>&1\nend\n\n# Remove any pre-existing completions for the program since we will be handling all of them.\ncomplete -c ${getAppBin(context)} -e\n# This will get called after the two calls below and clear the cached result\ncomplete -c ${getAppBin(context)} -n '__${snakeCase(getAppBin(context))}_clear_perform_completion_once_result'\n# The call to __${snakeCase(getAppBin(context))}_prepare_completions will setup __${snakeCase(getAppBin(context))}_comp_results\n# which provides the program's completion choices.\n# If this doesn't require order preservation, we don't use the -k flag\ncomplete -c ${getAppBin(\n context\n )} -n 'not __${snakeCase(getAppBin(context))}_requires_order_preservation && __${snakeCase(getAppBin(context))}_prepare_completions' -f -a '$__${snakeCase(getAppBin(context))}_comp_results'\n# Otherwise we use the -k flag\ncomplete -k -c ${getAppBin(context)} -n '__${snakeCase(\n getAppBin(context)\n )}_requires_order_preservation && __${snakeCase(\n getAppBin(context)\n )}_prepare_completions' -f -a '$__${snakeCase(\n getAppBin(context)\n )}_comp_results'\n\\`);`}\n />\n <Spacing />\n <IfStatement condition={code`options.config`}>\n <VarDeclaration\n let\n name=\"configFilePath\"\n type=\"string\"\n initializer={code`options.config === true ? \"~/.config/fish/config.fish\" : options.config`}\n />\n <Spacing />\n <IfStatement condition={code`configFilePath.startsWith(\"~\")`}>\n {code`configFilePath = join(os.homedir(), configFilePath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"configFileContent\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n configFileContent = await readFile(configFilePath, \"utf8\");\n } catch (error) {\n if (error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configFilePath, \\`\\${configFileContent}\\\\n\\\\n\\${stripAnsi(completions)}\\`);\n\n success(\\`${getAppTitle(context)} Fish completion script has been generated and appended to \\${colors.bold(configFilePath)}. Please restart your terminal or run \\`source \\${configFilePath}\\` to apply the changes.\\`); `}\n </IfStatement>\n <Spacing />\n <IfStatement condition={code`options.script`}>\n {code`const outputPath = options.script === true ? \"${getAppBin(context)}-completions.fish\" : options.script;\n await writeFile(outputPath, stripAnsi(completions));\n\n success(\\`${getAppTitle(context)} Fish completion script has been generated at \\${colors.bold(outputPath)}.\\`);`}\n </IfStatement>\n <Spacing />\n <IfStatement condition={code`!options.config && !options.script`}>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(completions);\n writeLine(\" ------------------------------------------------- \");`}\n </IfStatement>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,SAAS,yBAAwB;CACjC,MAAQ,UAAU,eAAwC;AAC1D,QAAS,gBAAkB,gBAAa;EACxC,IAAQ,OAAC;AACH,UAAO,UAAU,QAAE,WAAiB,eAAQ,QAAA,aAAA;;EAElD,SAAa;;GAEX,oBAAA,CAAA,YAAA,YAAA;GACC;EACD,gBAAA,EACI,uBAAU;GAAA;GAAwB;GAAC;GAAA;GAAA;GAAA,EACvC;;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;;EAEN,CAAC"}
|
|
1
|
+
{"version":3,"file":"fish-command.mjs","names":[],"sources":["../../src/components/fish-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue,\n TSDocRemarks\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport { CompletionDirective } from \"../helpers/completion-directive-constants\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions commands' handler wrapper for the Shell Shock project.\n */\nexport function FishCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n const name = computed(() => snakeCase(bin.value));\n\n return (\n <TypescriptFile\n path={joinPaths(context.entryPath, \"completions\", \"fish\", \"command.ts\")}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"]\n }}\n builtinImports={{\n \"shell-shock:console\": [\n \"colors\",\n \"writeLine\",\n \"success\",\n \"warn\",\n \"stripAnsi\"\n ]\n }}>\n <TSDoc heading=\"Options for the Fish completions command.\" />\n <InterfaceDeclaration export name=\"FishCompletionsOptions\">\n <TSDoc heading=\"The path to write the completion script to.\">\n <TSDocRemarks>{`If no extension is provided, the \\`.fish\\` extension will be used.`}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue={`${bin.value}-completions.fish`}\n />\n </TSDoc>\n <InterfaceMember name=\"script\" optional type=\"string | true\" />\n <Spacing />\n <TSDoc heading=\"The Fish configuration file to append the completion script to.\">\n <TSDocRemarks>{`The generated completion script will be appended to the specified configuration file. Possible values for the Fish configuration file include: \\\\n- \\`~/.config/fish/config.fish\\``}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue=\"~/.config/fish/config.fish\"\n />\n </TSDoc>\n <InterfaceMember name=\"config\" optional type=\"string | true\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions fish\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[{ name: \"options\", type: \"FishCompletionsOptions\" }]}>\n <VarDeclaration\n const\n name=\"completions\"\n type=\"string\"\n initializer={code` \\`# fish completion for ${getAppTitle(\n context\n )} -*- shell-script -*-\n\nfunction __${name.value}_debug\n set -l file \"$BASH_COMP_DEBUG_FILE\"\n if test -n \"$file\"\n echo \"$argv\" >> $file\n end\nend\n\nfunction __${name.value}_perform_completion\n __${name.value}_debug \"Starting __${name.value}_perform_completion\"\n\n # Extract all args except the last one\n set -l args (commandline -opc)\n # Extract the last arg and escape it in case it is a space or wildcard\n set -l lastArg (string escape -- (commandline -ct))\n\n __${name.value}_debug \"args: $args\"\n __${name.value}_debug \"last arg: $lastArg\"\n\n # Build the completion request command\n set -l requestComp \"${EXEC_COMMAND} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg\"\n\n __${name.value}_debug \"Calling $requestComp\"\n set -l results (eval $requestComp 2> /dev/null)\n\n # Some programs may output extra empty lines after the directive.\n # Let's ignore them or else it will break completion.\n # Ref: https://github.com/spf13/cobra/issues/1279\n for line in $results[-1..1]\n if test (string trim -- $line) = \"\"\n # Found an empty line, remove it\n set results $results[1..-2]\n else\n # Found non-empty line, we have our proper output\n break\n end\n end\n\n set -l comps $results[1..-2]\n set -l directiveLine $results[-1]\n\n # For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)\n # completions must be prefixed with the flag\n set -l flagPrefix (string match -r -- '-.*=' \"$lastArg\")\n\n __${name.value}_debug \"Comps: $comps\"\n __${name.value}_debug \"DirectiveLine: $directiveLine\"\n __${name.value}_debug \"flagPrefix: $flagPrefix\"\n\n for comp in $comps\n printf \"%s%s\\\\n\" \"$flagPrefix\" \"$comp\"\n end\n\n printf \"%s\\\\n\" \"$directiveLine\"\nend\n\n# This function limits calls to __${\n name.value\n }_perform_completion, by caching the result\nfunction __${name.value}_perform_completion_once\n __${name.value}_debug \"Starting __${name.value}_perform_completion_once\"\n\n if test -n \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"Seems like a valid result already exists, skipping __${name.value}_perform_completion\"\n return 0\n end\n\n set --global __${name.value}_perform_completion_once_result (__${\n name.value\n }_perform_completion)\n if test -z \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"No completions, probably due to a failure\"\n return 1\n end\n\n __${name.value}_debug \"Performed completions and set __${\n name.value\n }_perform_completion_once_result\"\n return 0\nend\n\n# This function is used to clear the cached result after completions are run\nfunction __${name.value}_clear_perform_completion_once_result\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= clearing previously set __${\n name.value\n }_perform_completion_once_result variable ==========\"\n set --erase __${name.value}_perform_completion_once_result\n __${name.value}_debug \"Successfully erased the variable __${\n name.value\n }_perform_completion_once_result\"\nend\n\nfunction __${name.value}_requires_order_preservation\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= checking if order preservation is required ==========\"\n\n __${name.value}_perform_completion_once\n if test -z \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"Error determining if order preservation is required\"\n return 1\n end\n\n set -l directive (string sub --start 2 $__$\n {name.value}_perform_completion_once_result[-1])\n __${name.value}_debug \"Directive is: $directive\"\n\n set -l shellCompDirectiveKeepOrder ${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)\n __${name.value}_debug \"Keeporder is: $keeporder\"\n\n if test $keeporder -ne 0\n __${name.value}_debug \"This does require order preservation\"\n return 0\n end\n\n __${name.value}_debug \"This doesn't require order preservation\"\n return 1\nend\n\n# This function does two things:\n# - Obtain the completions and store them in the global __${\n name.value\n }_comp_results\n# - Return false if file completion should be performed\nfunction __${name.value}_prepare_completions\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= starting completion logic ==========\"\n\n # Start fresh\n set --erase __${name.value}_comp_results\n\n __${name.value}_perform_completion_once\n __${name.value}_debug \"Completion results: $__${\n name.value\n }_perform_completion_once_result\"\n\n if test -z \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"No completion, probably due to a failure\"\n # Might as well do file completion, in case it helps\n return 1\n end\n\n set -l directive (string sub --start 2 $__${\n name.value\n }_perform_completion_once_result[-1])\n set --global __${name.value}_comp_results $__${\n name.value\n }_perform_completion_once_result[1..-2]\n\n __${name.value}_debug \"Completions are: $__${name.value}_comp_results\"\n __${name.value}_debug \"Directive is: $directive\"\n\n set -l shellCompDirectiveError ${\n CompletionDirective.CompletionDirectiveError\n }\n set -l shellCompDirectiveNoSpace ${\n CompletionDirective.CompletionDirectiveNoSpace\n }\n set -l shellCompDirectiveNoFileComp ${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\n set -l shellCompDirectiveFilterFileExt ${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\n set -l shellCompDirectiveFilterDirs ${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\n if test -z \"$directive\"\n set directive 0\n end\n\n set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)\n if test $compErr -eq 1\n __${name.value}_debug \"Received error directive: aborting.\"\n # Might as well do file completion, in case it helps\n return 1\n end\n\n set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)\n set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)\n if test $filefilter -eq 1; or test $dirfilter -eq 1\n __${name.value}_debug \"File extension filtering or directory filtering not supported\"\n # Do full file completion instead\n return 1\n end\n\n set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)\n set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)\n\n __${name.value}_debug \"nospace: $nospace, nofiles: $nofiles\"\n\n # If we want to prevent a space, or if file completion is NOT disabled,\n # we need to count the number of valid completions.\n # To do so, we will filter on prefix as the completions we have received\n # may not already be filtered so as to allow fish to match on different\n # criteria than the prefix.\n if test $nospace -ne 0; or test $nofiles -eq 0\n set -l prefix (commandline -t | string escape --style=regex)\n __${name.value}_debug \"prefix: $prefix\"\n\n set -l completions (string match -r -- \"^$prefix.*\" $__${\n name.value\n }_comp_results)\n set --global __${name.value}_comp_results $completions\n __${name.value}_debug \"Filtered completions are: $__${\n name.value\n }_comp_results\"\n\n # Important not to quote the variable for count to work\n set -l numComps (count $__${name.value}_comp_results)\n __${name.value}_debug \"numComps: $numComps\"\n\n if test $numComps -eq 1; and test $nospace -ne 0\n # We must first split on \\\\t to get rid of the descriptions to be\n # able to check what the actual completion will be.\n # We don't need descriptions anyway since there is only a single\n # real completion which the shell will expand immediately.\n set -l split (string split --max 1 \"\\\\t\" $__${\n name.value\n }_comp_results[1])\n\n # Fish won't add a space if the completion ends with any\n # of the following characters: @=/:.,\n set -l lastChar (string sub -s -1 -- $split)\n if not string match -r -q \"[@=/:.,]\" -- \"$lastChar\"\n # In other cases, to support the \"nospace\" directive we trick the shell\n # by outputting an extra, longer completion.\n __${name.value}_debug \"Adding second completion to perform nospace directive\"\n set --global __${name.value}_comp_results $split[1] $split[1].\n __${name.value}_debug \"Completions are now: $__${\n name.value\n }_comp_results\"\n end\n end\n\n if test $numComps -eq 0; and test $nofiles -eq 0\n # To be consistent with bash and zsh, we only trigger file\n # completion when there are no other completions\n __${name.value}_debug \"Requesting file completion\"\n return 1\n end\n end\n\n return 0\nend\n\n# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves\n# so we can properly delete any completions provided by another script.\n# Only do this if the program can be found, or else fish may print some errors; besides,\n# the existing completions will only be loaded if the program can be found.\nif type -q \"${bin.value}\"\n # The space after the program name is essential to trigger completion for the program\n # and not completion of the program name itself.\n # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.\n complete --do-complete \"${bin.value} \" > /dev/null 2>&1\nend\n\n# Remove any pre-existing completions for the program since we will be handling all of them.\ncomplete -c ${bin.value} -e\n# This will get called after the two calls below and clear the cached result\ncomplete -c ${bin.value} -n '__${name.value}_clear_perform_completion_once_result'\n# The call to __${name.value}_prepare_completions will setup __${\n name.value\n }_comp_results\n# which provides the program's completion choices.\n# If this doesn't require order preservation, we don't use the -k flag\ncomplete -c ${getAppBin(\n context\n )} -n 'not __${name.value}_requires_order_preservation && __${\n name.value\n }_prepare_completions' -f -a '$__${name.value}_comp_results'\n# Otherwise we use the -k flag\ncomplete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && __${\n name.value\n }_prepare_completions' -f -a '$__${name.value}_comp_results'\n\\`; `}\n />\n <Spacing />\n <IfStatement condition={code`options.config`}>\n <VarDeclaration\n let\n name=\"configFilePath\"\n type=\"string\"\n initializer={code`options.config === true ? \"~/.config/fish/config.fish\" : options.config`}\n />\n <Spacing />\n <IfStatement condition={code`configFilePath.startsWith(\"~\")`}>\n {code`configFilePath = join(os.homedir(), configFilePath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"configFileContent\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n configFileContent = await readFile(configFilePath, \"utf8\");\n } catch (error) {\n if (Error.isError(error) && error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configFilePath, \\`\\${configFileContent}\\\\n\\\\n\\${stripAnsi(completions)}\\`);\n\n success(\\`${getAppTitle(context)} Fish completion script has been generated and appended to \\${colors.bold(configFilePath)}. Please restart your terminal or run \\`source \\${configFilePath}\\` to apply the changes.\\`); `}\n </IfStatement>\n <Spacing />\n <IfStatement condition={code`options.script`}>\n {code`const outputPath = options.script === true ? \"${bin.value}-completions.fish\" : options.script;\n await writeFile(outputPath, stripAnsi(completions));\n\n success(\\`${getAppTitle(context)} Fish completion script has been generated at \\${colors.bold(outputPath)}.\\`);`}\n </IfStatement>\n <Spacing />\n <IfStatement condition={code`!options.config && !options.script`}>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(completions);\n writeLine(\" ------------------------------------------------- \");`}\n </IfStatement>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,SAAS,yBAAwB;CACjC,MAAQ,UAAU,eAAwC;CAC1D,MAAQ,MAAC,eAAmB,UAAW,QAAC,CAAA;CACxC,MAAQ,OAAC,eAAmB,UAAO,IAAO,MAAO,CAAA;AACjD,QAAS,gBAAe,gBAAiB;EACzC,IAAQ,OAAC;AACH,UAAO,UAAC,QAAA,WAA2B,eAAe,QAAO,aAAA;;EAE7D,SAAA;GACI,WAAM;GACV,aAAA,CAAA,OAAA;GACI,oBAAU,CAAA,YAAuB,YAAE;GACvC;oBAEA,uBAA2B;GAAA;GAAU;GAAS;GA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