@shell-shock/plugin-completions 0.4.14 → 0.4.16

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.
Files changed (57) hide show
  1. package/README.md +1 -1
  2. package/dist/components/bash-config-command.cjs +6 -120
  3. package/dist/components/bash-config-command.mjs +6 -119
  4. package/dist/components/bash-config-command.mjs.map +1 -1
  5. package/dist/components/bash-script-command.cjs +5 -105
  6. package/dist/components/bash-script-command.mjs +5 -104
  7. package/dist/components/bash-script-command.mjs.map +1 -1
  8. package/dist/components/bash-shared.cjs +13 -77
  9. package/dist/components/bash-shared.mjs +13 -76
  10. package/dist/components/bash-shared.mjs.map +1 -1
  11. package/dist/components/fish-config-command.cjs +6 -120
  12. package/dist/components/fish-config-command.mjs +6 -119
  13. package/dist/components/fish-config-command.mjs.map +1 -1
  14. package/dist/components/fish-script-command.cjs +4 -104
  15. package/dist/components/fish-script-command.mjs +4 -103
  16. package/dist/components/fish-script-command.mjs.map +1 -1
  17. package/dist/components/fish-shared.cjs +77 -141
  18. package/dist/components/fish-shared.mjs +77 -140
  19. package/dist/components/fish-shared.mjs.map +1 -1
  20. package/dist/components/index.cjs +1 -26
  21. package/dist/components/index.mjs +1 -14
  22. package/dist/components/powershell-config-command.cjs +6 -116
  23. package/dist/components/powershell-config-command.mjs +6 -115
  24. package/dist/components/powershell-config-command.mjs.map +1 -1
  25. package/dist/components/powershell-script-command.cjs +4 -104
  26. package/dist/components/powershell-script-command.mjs +4 -103
  27. package/dist/components/powershell-script-command.mjs.map +1 -1
  28. package/dist/components/powershell-shared.cjs +37 -101
  29. package/dist/components/powershell-shared.mjs +37 -100
  30. package/dist/components/powershell-shared.mjs.map +1 -1
  31. package/dist/components/zsh-config-command.cjs +6 -120
  32. package/dist/components/zsh-config-command.mjs +6 -119
  33. package/dist/components/zsh-config-command.mjs.map +1 -1
  34. package/dist/components/zsh-script-command.cjs +6 -108
  35. package/dist/components/zsh-script-command.mjs +6 -107
  36. package/dist/components/zsh-script-command.mjs.map +1 -1
  37. package/dist/components/zsh-shared.cjs +42 -106
  38. package/dist/components/zsh-shared.mjs +42 -105
  39. package/dist/components/zsh-shared.mjs.map +1 -1
  40. package/dist/helpers/complete-command.cjs +1 -10
  41. package/dist/helpers/complete-command.mjs +1 -8
  42. package/dist/helpers/complete-command.mjs.map +1 -1
  43. package/dist/helpers/completion-directive-constants.cjs +1 -16
  44. package/dist/helpers/completion-directive-constants.mjs +1 -14
  45. package/dist/helpers/completion-directive-constants.mjs.map +1 -1
  46. package/dist/helpers/index.cjs +1 -6
  47. package/dist/helpers/index.mjs +1 -4
  48. package/dist/index.cjs +1 -303
  49. package/dist/index.mjs +1 -301
  50. package/dist/index.mjs.map +1 -1
  51. package/dist/types/index.cjs +1 -4
  52. package/dist/types/index.mjs +1 -3
  53. package/dist/types/plugin.mjs +1 -1
  54. package/dist/types/shell-type.cjs +1 -12
  55. package/dist/types/shell-type.mjs +1 -10
  56. package/dist/types/shell-type.mjs.map +1 -1
  57. package/package.json +10 -10
@@ -1,72 +1,25 @@
1
- import { EXEC_COMMAND } from "../helpers/complete-command.mjs";
2
- import { CompletionDirective } from "../helpers/completion-directive-constants.mjs";
3
- import "../helpers/index.mjs";
4
- import { createComponent } from "@alloy-js/core/jsx-runtime";
5
- import { getAppBin } from "@shell-shock/core/plugin-utils";
6
- import { code, computed } from "@alloy-js/core";
7
- import { VarDeclaration } from "@alloy-js/typescript";
8
- import { Spacing } from "@powerlines/plugin-alloy/core";
9
- import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
10
- import { TypescriptFile } from "@powerlines/plugin-alloy/typescript";
11
- import { joinPaths } from "@stryke/path";
12
- import { snakeCase } from "@stryke/string-format/snake-case";
13
-
14
- //#region src/components/fish-shared.tsx
15
- /**
16
- * The Fish Completions generation for the Shell Shock project.
17
- */
18
- function FishCompletionsShared() {
19
- const context = usePowerlines();
20
- const bin = computed(() => getAppBin(context));
21
- const name = computed(() => snakeCase(bin.value));
22
- return createComponent(TypescriptFile, {
23
- get path() {
24
- return joinPaths(context.entryPath, "completions", "fish", "shared.ts");
25
- },
26
- builtinImports: { console: [
27
- "white",
28
- "green",
29
- "red",
30
- "bold",
31
- "cyan",
32
- "gray",
33
- "magenta",
34
- "magentaBright",
35
- "greenBright",
36
- "redBright",
37
- "cyanBright",
38
- "dim"
39
- ] },
40
- get children() {
41
- return [
42
- createComponent(Spacing, {}),
43
- createComponent(VarDeclaration, {
44
- "const": true,
45
- "export": true,
46
- name: "SHELL_COMPLETIONS",
47
- get initializer() {
48
- return code` \`function __${name.value}_debug
1
+ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{CompletionDirective as t}from"../helpers/completion-directive-constants.mjs";import"../helpers/index.mjs";import{createComponent as n}from"@alloy-js/core/jsx-runtime";import{getAppBin as r}from"@shell-shock/core/plugin-utils";import{code as i,computed as a}from"@alloy-js/core";import{VarDeclaration as o}from"@alloy-js/typescript";import{Spacing as s}from"@powerlines/plugin-alloy/core";import{usePowerlines as c}from"@powerlines/plugin-alloy/core/contexts/context";import{TypescriptFile as l}from"@powerlines/plugin-alloy/typescript";import{joinPaths as u}from"@stryke/path";import{snakeCase as d}from"@stryke/string-format/snake-case";function f(){let f=c(),p=a(()=>r(f)),m=a(()=>d(p.value));return n(l,{get path(){return u(f.entryPath,`completions`,`fish`,`shared.ts`)},builtinImports:{console:[`white`,`green`,`red`,`bold`,`cyan`,`gray`,`magenta`,`magentaBright`,`greenBright`,`redBright`,`cyanBright`,`dim`]},get children(){return[n(s,{}),n(o,{const:!0,export:!0,name:`SHELL_COMPLETIONS`,get initializer(){return i` \`function __${m.value}_debug
49
2
  set -l file "$BASH_COMP_DEBUG_FILE"
50
3
  if test -n "$file"
51
4
  echo "$argv" >> $file
52
5
  end
53
6
  end
54
7
 
55
- function __${name.value}_perform_completion
56
- __${name.value}_debug "Starting __${name.value}_perform_completion"
8
+ function __${m.value}_perform_completion
9
+ __${m.value}_debug "Starting __${m.value}_perform_completion"
57
10
 
58
11
  # Extract all args except the last one
59
12
  set -l args (commandline -opc)
60
13
  # Extract the last arg and escape it in case it is a space or wildcard
61
14
  set -l lastArg (string escape -- (commandline -ct))
62
15
 
63
- __${name.value}_debug "args: $args"
64
- __${name.value}_debug "last arg: $lastArg"
16
+ __${m.value}_debug "args: $args"
17
+ __${m.value}_debug "last arg: $lastArg"
65
18
 
66
19
  # Build the completion request command
67
- set -l requestComp "${EXEC_COMMAND} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
20
+ set -l requestComp "${e} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
68
21
 
69
- __${name.value}_debug "Calling $requestComp"
22
+ __${m.value}_debug "Calling $requestComp"
70
23
  set -l results (eval $requestComp 2> /dev/null)
71
24
 
72
25
  # Some programs may output extra empty lines after the directive.
@@ -89,9 +42,9 @@ function __${name.value}_perform_completion
89
42
  # completions must be prefixed with the flag
90
43
  set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
91
44
 
92
- __${name.value}_debug "Comps: $comps"
93
- __${name.value}_debug "DirectiveLine: $directiveLine"
94
- __${name.value}_debug "flagPrefix: $flagPrefix"
45
+ __${m.value}_debug "Comps: $comps"
46
+ __${m.value}_debug "DirectiveLine: $directiveLine"
47
+ __${m.value}_debug "flagPrefix: $flagPrefix"
95
48
 
96
49
  for comp in $comps
97
50
  printf "%s%s\\n" "$flagPrefix" "$comp"
@@ -100,96 +53,96 @@ function __${name.value}_perform_completion
100
53
  printf "%s\\n" "$directiveLine"
101
54
  end
102
55
 
103
- # This function limits calls to __${name.value}_perform_completion, by caching the result
104
- function __${name.value}_perform_completion_once
105
- __${name.value}_debug "Starting __${name.value}_perform_completion_once"
56
+ # This function limits calls to __${m.value}_perform_completion, by caching the result
57
+ function __${m.value}_perform_completion_once
58
+ __${m.value}_debug "Starting __${m.value}_perform_completion_once"
106
59
 
107
- if test -n "$__${name.value}_perform_completion_once_result"
108
- __${name.value}_debug "Seems like a valid result already exists, skipping __${name.value}_perform_completion"
60
+ if test -n "$__${m.value}_perform_completion_once_result"
61
+ __${m.value}_debug "Seems like a valid result already exists, skipping __${m.value}_perform_completion"
109
62
  return 0
110
63
  end
111
64
 
112
- set --global __${name.value}_perform_completion_once_result (__${name.value}_perform_completion)
113
- if test -z "$__${name.value}_perform_completion_once_result"
114
- __${name.value}_debug "No completions, probably due to a failure"
65
+ set --global __${m.value}_perform_completion_once_result (__${m.value}_perform_completion)
66
+ if test -z "$__${m.value}_perform_completion_once_result"
67
+ __${m.value}_debug "No completions, probably due to a failure"
115
68
  return 1
116
69
  end
117
70
 
118
- __${name.value}_debug "Performed completions and set __${name.value}_perform_completion_once_result"
71
+ __${m.value}_debug "Performed completions and set __${m.value}_perform_completion_once_result"
119
72
  return 0
120
73
  end
121
74
 
122
75
  # This function is used to clear the cached result after completions are run
123
- function __${name.value}_clear_perform_completion_once_result
124
- __${name.value}_debug ""
125
- __${name.value}_debug "========= clearing previously set __${name.value}_perform_completion_once_result variable =========="
126
- set --erase __${name.value}_perform_completion_once_result
127
- __${name.value}_debug "Successfully erased the variable __${name.value}_perform_completion_once_result"
76
+ function __${m.value}_clear_perform_completion_once_result
77
+ __${m.value}_debug ""
78
+ __${m.value}_debug "========= clearing previously set __${m.value}_perform_completion_once_result variable =========="
79
+ set --erase __${m.value}_perform_completion_once_result
80
+ __${m.value}_debug "Successfully erased the variable __${m.value}_perform_completion_once_result"
128
81
  end
129
82
 
130
- function __${name.value}_requires_order_preservation
131
- __${name.value}_debug ""
132
- __${name.value}_debug "========= checking if order preservation is required =========="
83
+ function __${m.value}_requires_order_preservation
84
+ __${m.value}_debug ""
85
+ __${m.value}_debug "========= checking if order preservation is required =========="
133
86
 
134
- __${name.value}_perform_completion_once
135
- if test -z "$__${name.value}_perform_completion_once_result"
136
- __${name.value}_debug "Error determining if order preservation is required"
87
+ __${m.value}_perform_completion_once
88
+ if test -z "$__${m.value}_perform_completion_once_result"
89
+ __${m.value}_debug "Error determining if order preservation is required"
137
90
  return 1
138
91
  end
139
92
 
140
- set -l directive (string sub --start 2 $__${name.value}_perform_completion_once_result[-1])
141
- __${name.value}_debug "Directive is: $directive"
93
+ set -l directive (string sub --start 2 $__${m.value}_perform_completion_once_result[-1])
94
+ __${m.value}_debug "Directive is: $directive"
142
95
 
143
- set -l shellCompDirectiveKeepOrder ${CompletionDirective.CompletionDirectiveKeepOrder}
96
+ set -l shellCompDirectiveKeepOrder ${t.CompletionDirectiveKeepOrder}
144
97
  set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
145
- __${name.value}_debug "Keeporder is: $keeporder"
98
+ __${m.value}_debug "Keeporder is: $keeporder"
146
99
 
147
100
  if test $keeporder -ne 0
148
- __${name.value}_debug "This does require order preservation"
101
+ __${m.value}_debug "This does require order preservation"
149
102
  return 0
150
103
  end
151
104
 
152
- __${name.value}_debug "This doesn't require order preservation"
105
+ __${m.value}_debug "This doesn't require order preservation"
153
106
  return 1
154
107
  end
155
108
 
156
109
  # This function does two things:
157
- # - Obtain the completions and store them in the global __${name.value}_comp_results
110
+ # - Obtain the completions and store them in the global __${m.value}_comp_results
158
111
  # - Return false if file completion should be performed
159
- function __${name.value}_prepare_completions
160
- __${name.value}_debug ""
161
- __${name.value}_debug "========= starting completion logic =========="
112
+ function __${m.value}_prepare_completions
113
+ __${m.value}_debug ""
114
+ __${m.value}_debug "========= starting completion logic =========="
162
115
 
163
116
  # Start fresh
164
- set --erase __${name.value}_comp_results
117
+ set --erase __${m.value}_comp_results
165
118
 
166
- __${name.value}_perform_completion_once
167
- __${name.value}_debug "Completion results: $__${name.value}_perform_completion_once_result"
119
+ __${m.value}_perform_completion_once
120
+ __${m.value}_debug "Completion results: $__${m.value}_perform_completion_once_result"
168
121
 
169
- if test -z "$__${name.value}_perform_completion_once_result"
170
- __${name.value}_debug "No completion, probably due to a failure"
122
+ if test -z "$__${m.value}_perform_completion_once_result"
123
+ __${m.value}_debug "No completion, probably due to a failure"
171
124
  # Might as well do file completion, in case it helps
172
125
  return 1
173
126
  end
174
127
 
175
- set -l directive (string sub --start 2 $__${name.value}_perform_completion_once_result[-1])
176
- set --global __${name.value}_comp_results $__${name.value}_perform_completion_once_result[1..-2]
128
+ set -l directive (string sub --start 2 $__${m.value}_perform_completion_once_result[-1])
129
+ set --global __${m.value}_comp_results $__${m.value}_perform_completion_once_result[1..-2]
177
130
 
178
- __${name.value}_debug "Completions are: $__${name.value}_comp_results"
179
- __${name.value}_debug "Directive is: $directive"
131
+ __${m.value}_debug "Completions are: $__${m.value}_comp_results"
132
+ __${m.value}_debug "Directive is: $directive"
180
133
 
181
- set -l shellCompDirectiveError ${CompletionDirective.CompletionDirectiveError}
182
- set -l shellCompDirectiveNoSpace ${CompletionDirective.CompletionDirectiveNoSpace}
183
- set -l shellCompDirectiveNoFileComp ${CompletionDirective.CompletionDirectiveNoFileComp}
184
- set -l shellCompDirectiveFilterFileExt ${CompletionDirective.CompletionDirectiveFilterFileExt}
185
- set -l shellCompDirectiveFilterDirs ${CompletionDirective.CompletionDirectiveFilterDirs}
134
+ set -l shellCompDirectiveError ${t.CompletionDirectiveError}
135
+ set -l shellCompDirectiveNoSpace ${t.CompletionDirectiveNoSpace}
136
+ set -l shellCompDirectiveNoFileComp ${t.CompletionDirectiveNoFileComp}
137
+ set -l shellCompDirectiveFilterFileExt ${t.CompletionDirectiveFilterFileExt}
138
+ set -l shellCompDirectiveFilterDirs ${t.CompletionDirectiveFilterDirs}
186
139
  if test -z "$directive"
187
140
  set directive 0
188
141
  end
189
142
 
190
143
  set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
191
144
  if test $compErr -eq 1
192
- __${name.value}_debug "Received error directive: aborting."
145
+ __${m.value}_debug "Received error directive: aborting."
193
146
  # Might as well do file completion, in case it helps
194
147
  return 1
195
148
  end
@@ -197,7 +150,7 @@ function __${name.value}_prepare_completions
197
150
  set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
198
151
  set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
199
152
  if test $filefilter -eq 1; or test $dirfilter -eq 1
200
- __${name.value}_debug "File extension filtering or directory filtering not supported"
153
+ __${m.value}_debug "File extension filtering or directory filtering not supported"
201
154
  # Do full file completion instead
202
155
  return 1
203
156
  end
@@ -205,7 +158,7 @@ function __${name.value}_prepare_completions
205
158
  set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
206
159
  set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
207
160
 
208
- __${name.value}_debug "nospace: $nospace, nofiles: $nofiles"
161
+ __${m.value}_debug "nospace: $nospace, nofiles: $nofiles"
209
162
 
210
163
  # If we want to prevent a space, or if file completion is NOT disabled,
211
164
  # we need to count the number of valid completions.
@@ -214,22 +167,22 @@ function __${name.value}_prepare_completions
214
167
  # criteria than the prefix.
215
168
  if test $nospace -ne 0; or test $nofiles -eq 0
216
169
  set -l prefix (commandline -t | string escape --style=regex)
217
- __${name.value}_debug "prefix: $prefix"
170
+ __${m.value}_debug "prefix: $prefix"
218
171
 
219
- set -l completions (string match -r -- "^$prefix.*" $__${name.value}_comp_results)
220
- set --global __${name.value}_comp_results $completions
221
- __${name.value}_debug "Filtered completions are: $__${name.value}_comp_results"
172
+ set -l completions (string match -r -- "^$prefix.*" $__${m.value}_comp_results)
173
+ set --global __${m.value}_comp_results $completions
174
+ __${m.value}_debug "Filtered completions are: $__${m.value}_comp_results"
222
175
 
223
176
  # Important not to quote the variable for count to work
224
- set -l numComps (count $__${name.value}_comp_results)
225
- __${name.value}_debug "numComps: $numComps"
177
+ set -l numComps (count $__${m.value}_comp_results)
178
+ __${m.value}_debug "numComps: $numComps"
226
179
 
227
180
  if test $numComps -eq 1; and test $nospace -ne 0
228
181
  # We must first split on \\t to get rid of the descriptions to be
229
182
  # able to check what the actual completion will be.
230
183
  # We don't need descriptions anyway since there is only a single
231
184
  # real completion which the shell will expand immediately.
232
- set -l split (string split --max 1 "\\t" $__${name.value}_comp_results[1])
185
+ set -l split (string split --max 1 "\\t" $__${m.value}_comp_results[1])
233
186
 
234
187
  # Fish won't add a space if the completion ends with any
235
188
  # of the following characters: @=/:.,
@@ -237,16 +190,16 @@ function __${name.value}_prepare_completions
237
190
  if not string match -r -q "[@=/:.,]" -- "$lastChar"
238
191
  # In other cases, to support the "nospace" directive we trick the shell
239
192
  # by outputting an extra, longer completion.
240
- __${name.value}_debug "Adding second completion to perform nospace directive"
241
- set --global __${name.value}_comp_results $split[1] $split[1].
242
- __${name.value}_debug "Completions are now: $__${name.value}_comp_results"
193
+ __${m.value}_debug "Adding second completion to perform nospace directive"
194
+ set --global __${m.value}_comp_results $split[1] $split[1].
195
+ __${m.value}_debug "Completions are now: $__${m.value}_comp_results"
243
196
  end
244
197
  end
245
198
 
246
199
  if test $numComps -eq 0; and test $nofiles -eq 0
247
200
  # To be consistent with bash and zsh, we only trigger file
248
201
  # completion when there are no other completions
249
- __${name.value}_debug "Requesting file completion"
202
+ __${m.value}_debug "Requesting file completion"
250
203
  return 1
251
204
  end
252
205
  end
@@ -258,32 +211,24 @@ end
258
211
  # so we can properly delete any completions provided by another script.
259
212
  # Only do this if the program can be found, or else fish may print some errors; besides,
260
213
  # the existing completions will only be loaded if the program can be found.
261
- if type -q "${bin.value}"
214
+ if type -q "${p.value}"
262
215
  # The space after the program name is essential to trigger completion for the program
263
216
  # and not completion of the program name itself.
264
217
  # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
265
- complete --do-complete "${bin.value} " > /dev/null 2>&1
218
+ complete --do-complete "${p.value} " > /dev/null 2>&1
266
219
  end
267
220
 
268
221
  # Remove any pre-existing completions for the program since we will be handling all of them.
269
- complete -c ${bin.value} -e
222
+ complete -c ${p.value} -e
270
223
  # This will get called after the two calls below and clear the cached result
271
- complete -c ${bin.value} -n '__${name.value}_clear_perform_completion_once_result'
272
- # The call to __${name.value}_prepare_completions will setup __${name.value}_comp_results
224
+ complete -c ${p.value} -n '__${m.value}_clear_perform_completion_once_result'
225
+ # The call to __${m.value}_prepare_completions will setup __${m.value}_comp_results
273
226
  # which provides the program's completion choices.
274
227
  # If this doesn't require order preservation, we don't use the -k flag
275
- complete -c ${getAppBin(context)} -n 'not __${name.value}_requires_order_preservation && __${name.value}_prepare_completions' -f -a '$__${name.value}_comp_results'
228
+ complete -c ${r(f)} -n 'not __${m.value}_requires_order_preservation && __${m.value}_prepare_completions' -f -a '$__${m.value}_comp_results'
276
229
  # Otherwise we use the -k flag
277
- complete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && __${name.value}_prepare_completions' -f -a '$__${name.value}_comp_results'
278
- \`; `;
279
- }
280
- }),
281
- createComponent(Spacing, {}),
282
- createComponent(VarDeclaration, {
283
- "export": true,
284
- "const": true,
285
- name: "SHELL_COMPLETIONS_DISPLAY",
286
- initializer: code` SHELL_COMPLETIONS.split("\\n").map(line => {
230
+ complete -k -c ${p.value} -n '__${m.value}_requires_order_preservation && __${m.value}_prepare_completions' -f -a '$__${m.value}_comp_results'
231
+ \`; `}}),n(s,{}),n(o,{export:!0,const:!0,name:`SHELL_COMPLETIONS_DISPLAY`,initializer:i` SHELL_COMPLETIONS.split("\\n").map(line => {
287
232
  if (!line.trim()) {
288
233
  return "";
289
234
  }
@@ -304,13 +249,5 @@ complete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && _
304
249
  .replaceAll(/\\s__\\w/g, bold(magentaBright("$&")))
305
250
  .replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
306
251
 
307
- }).join("\\n"); `
308
- })
309
- ];
310
- }
311
- });
312
- }
313
-
314
- //#endregion
315
- export { FishCompletionsShared };
252
+ }).join("\\n"); `})]}})}export{f as FishCompletionsShared};
316
253
  //# sourceMappingURL=fish-shared.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fish-shared.mjs","names":[],"sources":["../../src/components/fish-shared.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 { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions generation for the Shell Shock project.\n */\nexport function FishCompletionsShared() {\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\", \"shared.ts\")}\n builtinImports={{\n console: [\n \"white\",\n \"green\",\n \"red\",\n \"bold\",\n \"cyan\",\n \"gray\",\n \"magenta\",\n \"magentaBright\",\n \"greenBright\",\n \"redBright\",\n \"cyanBright\",\n \"dim\"\n ]\n }}>\n <Spacing />\n <VarDeclaration\n const\n export\n name=\"SHELL_COMPLETIONS\"\n initializer={code` \\`function __${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\n }_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 <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS_DISPLAY\"\n initializer={code` SHELL_COMPLETIONS.split(\"\\\\n\").map(line => {\n if (!line.trim()) {\n return \"\";\n }\n if (line.trim().startsWith(\"#\")) {\n return \\`\\${dim(line)}\\`;\n }\n\n return white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, green(\"$&\"))\n .replaceAll(/(\\\\\"|\\\\').*(\\\\\"|\\\\')/g, cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|:)/g, bold(gray(\"$&\")))\n .replaceAll(/(function|complete)\\\\s+/g, green(\"$&\"))\n .replaceAll(/(?<=(function|complete)\\\\s+)\\\\w/g, bold(greenBright(\"$&\")))\n .replaceAll(/set\\\\s+/g, red(\"$&\"))\n .replaceAll(/(?<=set\\\\s+)\\\\w/g, bold(redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, bold(cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, green(\"$&\"))\n .replaceAll(/\\\\s__\\\\w/g, bold(magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, bold(magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkCA,SAAgB,wBAAgB;;CAE9B,MAAM,MAAM,eAAe,UAAU,QAAQ,CAAC;CAC9C,MAAM,OAAO,eAAe,UAAU,IAAI,MAAM,CAAC;;EAEjD,IAAM,OAAC;AACJ,UAAA,UAAA,QAAA,WAAA,eAAA,QAAA,YAAA;;EAED,gBAAgB,EACd,SAAS;GAAC;GAAC;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA,EACZ;EACD,IAAI,WAAS;AACX,UAAK;IAAG,gBAAC,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACP,SAAQ;KACR,UAAQ;KACR,MAAG;KACH,IAAG,cAAQ;AACT,aAAC,IAAA,iBAAc,KAAA,MAAA;;;;;;;aAOlB,KAAS,MAAA;QACT,KAAA,MAAA,qBAAA,KAAA,MAAA;;;;;;;QAOC,KAAK,MAAM;QACf,KAAA,MAAA;;;0BAGoB,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;QAyBhB,KAAK,MAAM;QACX,KAAI,MAAA;QACJ,KAAA,MAAA;;;;;;;;;;aAUK,KAAK,MAAC;QACX,KAAK,MAAM,qBAAqB,KAAG,MAAA;;;YAG/B,KAAK,MAAA,+DAAA,KAAA,MAAA;;;;qBAII,KAAA,MAAA,qCAAa,KAAA,MAAA;qBAClC,KAAA,MAAA;;;;;QAKQ,KAAK,MAAK,0CAAM,KAAA,MAAA;;;;;aAKhB,KAAO,MAAA;QACX,KAAA,MAAA;;oBAEgB,KAAK,MAAM;QACzB,KAAK,MAAA,6CAAA,KAAA,MAAA;;;aAGC,KAAK,MAAM;QACf,KAAA,MAAO;QACX,KAAA,MAAA;;QAEI,KAAK,MAAM;qBACR,KAAA,MAAA;YACN,KAAA,MAAA;;;;gDAIuC,KAAO,MAAM;QACjD,KAAK,MAAK;;yCAEmB,oBAAwB,6BAAG;;QAE3D,KAAA,MAAA;;;YAGM,KAAA,MAAA;;;;QAIH,KAAK,MAAK;;;;;4DAKc,KAA+B,MAAA;;aAEvD,KAAO,MAAA;QACX,KAAA,MAAA;;;;oBAIC,KAAA,MAAA;;;QAGG,KAAG,MAAA,iCAA6B,KAAA,MAAA;;qBAEpC,KAAA,MAAA;YACO,KAAA,MAAW;;;;;gDAKP,KAAA,MAAA;qBACX,KAAA,MAAA,mBAAA,KAAA,MAAA;;QAEI,KAAK,MAAM,8BAA6B,KAAM,MAAA;QAClD,KAAO,MAAA;;;uCAGoB,oBAAA,2BAAA;0CACW,oBAAiB,8BAAA;6CAC5C,oBAAA,iCAAA;0CACN,oBAAA,8BAAA;;;;;;;YAOC,KAAM,MAAI;;;;;;;;YAQR,KAAK,MAAM;;;;;;;;QAQf,KAAE,MAAS;;;;;;;;;YASf,KAAA,MAAA;;iEAEsB,KAAA,MAAA;yBACtB,KAAA,MAAA;YACO,KAAA,MAAA,uCAA8B,KAAA,MAAA;;;oCAG9B,KAAA,MAAiC;YACtC,KAAA,MAAA;;;;;;;0DAOF,KAAA,MAAA;;;;;;;;;iCAS6B,KAAG,MAAQ;oBACxB,KAAE,MAAM,kCAA6B,KAAA,MAAA;;;;;;;gBAO9C,KAAS,MAAM;;;;;;;;;;;;cAYd,IAAK,MAAM;;;;8BAID,IAAA,MAAA;;;;cAIb,IAAA,MAAa;;cAEZ,IAAA,MAAc,SAAS,KAAI,MAAA;kBACtB,KAAQ,MAAE,oCAAmC,KAAA,MAAA;;;cAGjD,UAAM,QAAe,CAAC,aAAU,KAAQ,MAAI,oCAAA,KAAA,MAAA,kCAAA,KAAA,MAAA;;iBAEzC,IAAO,MAAM,SAAS,KAAC,MAAO,oCAAkB,KAAA,MAAA,kCAAA,KAAA,MAAA;;;KAGvD,CAAC;IAAE,gBAAgB,SAAO,EAAM,CAAC;IAAC,gBAAgB,gBAAA;KACjD,UAAU;KACV,SAAK;;KAEL,aAAW,IAAM;;;;;;;;;;;;;;;;;;;;;;KAsBrB,CAAA;IAAA"}
1
+ {"version":3,"file":"fish-shared.mjs","names":[],"sources":["../../src/components/fish-shared.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 { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions generation for the Shell Shock project.\n */\nexport function FishCompletionsShared() {\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\", \"shared.ts\")}\n builtinImports={{\n console: [\n \"white\",\n \"green\",\n \"red\",\n \"bold\",\n \"cyan\",\n \"gray\",\n \"magenta\",\n \"magentaBright\",\n \"greenBright\",\n \"redBright\",\n \"cyanBright\",\n \"dim\"\n ]\n }}>\n <Spacing />\n <VarDeclaration\n const\n export\n name=\"SHELL_COMPLETIONS\"\n initializer={code` \\`function __${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\n }_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 <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS_DISPLAY\"\n initializer={code` SHELL_COMPLETIONS.split(\"\\\\n\").map(line => {\n if (!line.trim()) {\n return \"\";\n }\n if (line.trim().startsWith(\"#\")) {\n return \\`\\${dim(line)}\\`;\n }\n\n return white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, green(\"$&\"))\n .replaceAll(/(\\\\\"|\\\\').*(\\\\\"|\\\\')/g, cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|:)/g, bold(gray(\"$&\")))\n .replaceAll(/(function|complete)\\\\s+/g, green(\"$&\"))\n .replaceAll(/(?<=(function|complete)\\\\s+)\\\\w/g, bold(greenBright(\"$&\")))\n .replaceAll(/set\\\\s+/g, red(\"$&\"))\n .replaceAll(/(?<=set\\\\s+)\\\\w/g, bold(redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, bold(cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, green(\"$&\"))\n .replaceAll(/\\\\s__\\\\w/g, bold(magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, bold(magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":"osBAgCA,SAAE,GAAA,CACF,IAAO,EAAS,GAAA,CACR,EAAA,MAAU,EAAc,EAAA,CAAA,qBAE9B,OAAM,EAAmB,EAAY,CACrC,IAAM,MAAO,yDAGX,eAAC,CACC,QAAM,CAAA,QAAU,QAAQ,MAAW,OAAC,OAAe,OAAQ,UAAW,gBAAA,cAAA,YAAA,aAAA,MAAA,CACvE,CACD,IAAI,UAAS,CACX,MAAK,CAAA,EAAM,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACT,MAAS,GACT,OAAO,GACP,KAAG,oBACH,IAAG,aAAK,CACN,MAAM,EAAA,iBAAA,EAAA,MAAA;;;;;;;aAOR,EAAA,MAAA;QACA,EAAA,MAAA,qBAAA,EAAA,MAAA;;;;;;;QAOA,EAAG,MAAO;QACX,EAAM,MAAI;;;;;QAKT,EAAK,MAAK;;;;;;;;;;;;;;;;;;;;;;;QAuBV,EAAI,MAAI;QACR,EAAA,MAAA;QACA,EAAK,MAAM;;;;;;;;;oCASgB,EAAK,MAAI;aACjC,EAAA,MAAY;;;qBAGJ,EAAO,MAAC;YACf,EAAC,MAAM,+DAA+B,EAAA,MAAA;;;;qBAI9C,EAAA,MAAA,qCAAA,EAAA,MAAA;;YAEQ,EAAK,MAAI;;;;QAIb,EAAE,MAAK,0CAAA,EAAA,MAAA;;;;;aAKF,EAAI,MAAI;QACb,EAAI,MAAK;QACT,EAAA,MAAO,8CAAA,EAAA,MAAA;oBACX,EAAA,MAAA;;;;aAIC,EAAA,MAAmB;QACjB,EAAM,MAAM;QACX,EAAI,MAAK;;QAEb,EAAA,MAAA;;YAEQ,EAAC,MAAM;;;;;;;yCAOK,EAAA,6BAAA;;QAEhB,EAAK,MAAM;;;YAGT,EAAM,MAAI;;;;QAIpB,EAAA,MAAA;;;;;;;aAOa,EAAI,MAAI;QACb,EAAI,MAAK;QACT,EAAA,MAAO;;;oBAGK,EAAE,MAAO;;QAExB,EAAA,MAAA;QACG,EAAK,MAAM,iCAAgC,EAAA,MAAA;;qBAExC,EAAA,MAAA;YACL,EAAA,MAAA;;;;;gDAKqB,EAAA,MAAA;qBACV,EAAM,MAAQ,mBAAkB,EAAM,MAAA;;QAEnD,EAAA,MAAA,8BAAA,EAAA,MAAA;;;qCAGO,EAAA,yBAAA;;;6CAGoB,EAAA,iCAAA;0CACW,EAAiB,8BAAA;;;;;;;;;;;;;;;;;;;;;;;QAuBrD,EAAK,MAAA;;;;;;;;;YASA,EAAA,MAAA;;iEAEP,EAAA,MAAA;yBACO,EAAA,MAAyB;YAC9B,EAAA,MAAA,uCAAoB,EAAA,MAAA;;;oCAGA,EAAA,MAAA;YACtB,EAAA,MAAA;;;;;;;0DAOsB,EAAA,MAAA;;;;;;;;oBAQX,EAAA,MAAA;iCACX,EAAA,MAAA;;;;;;;;gBAQA,EAAA,MAAA;;;;;;;;;;;;cAYS,EAAA,MAAW;;;;8BAII,EAAM,MAAM;;;;cAI5B,EAAK,MAAM;;cAEd,EAAA,MAAa,SAAA,EAAA,MAAA;;;;cAIV,EAAW,EAAQ,CAAA,aAAW,EAAQ,MAAA,oCAAA,EAAA,MAAA,kCAAA,EAAA,MAAA;;iBAEjC,EAAA,MAAU,SAAS,EAAK,MAAE,oCAAY,EAAA,MAAA,kCAAA,EAAA,MAAA;OAGhD,CAAC,CAAE,EAAkB,EAAA,EAAA,CAAY,CAAC,EAAmB,EAAU,CAC9D,OAAU,GACV,MAAS,GACT,KAAM,4BACN,YAAK,CAAA;;;;;;;;;;;;;;;;;;;;;0BAsBT,CAAA,CAAA,EAED,CAAC"}
@@ -1,26 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_components_bash_config_command = require('./bash-config-command.cjs');
3
- const require_components_bash_script_command = require('./bash-script-command.cjs');
4
- const require_components_bash_shared = require('./bash-shared.cjs');
5
- const require_components_fish_config_command = require('./fish-config-command.cjs');
6
- const require_components_fish_script_command = require('./fish-script-command.cjs');
7
- const require_components_fish_shared = require('./fish-shared.cjs');
8
- const require_components_powershell_config_command = require('./powershell-config-command.cjs');
9
- const require_components_powershell_script_command = require('./powershell-script-command.cjs');
10
- const require_components_powershell_shared = require('./powershell-shared.cjs');
11
- const require_components_zsh_config_command = require('./zsh-config-command.cjs');
12
- const require_components_zsh_script_command = require('./zsh-script-command.cjs');
13
- const require_components_zsh_shared = require('./zsh-shared.cjs');
14
-
15
- exports.BashCompletionsShared = require_components_bash_shared.BashCompletionsShared;
16
- exports.BashConfigCompletionsCommand = require_components_bash_config_command.BashConfigCompletionsCommand;
17
- exports.BashScriptCompletionsCommand = require_components_bash_script_command.BashScriptCompletionsCommand;
18
- exports.FishCompletionsShared = require_components_fish_shared.FishCompletionsShared;
19
- exports.FishConfigCompletionsCommand = require_components_fish_config_command.FishConfigCompletionsCommand;
20
- exports.FishScriptCompletionsCommand = require_components_fish_script_command.FishScriptCompletionsCommand;
21
- exports.PowerShellCompletionsShared = require_components_powershell_shared.PowerShellCompletionsShared;
22
- exports.PowerShellConfigCompletionsCommand = require_components_powershell_config_command.PowerShellConfigCompletionsCommand;
23
- exports.PowerShellScriptCompletionsCommand = require_components_powershell_script_command.PowerShellScriptCompletionsCommand;
24
- exports.ZshCompletionsShared = require_components_zsh_shared.ZshCompletionsShared;
25
- exports.ZshConfigCompletionsCommand = require_components_zsh_config_command.ZshConfigCompletionsCommand;
26
- exports.ZshScriptCompletionsCommand = require_components_zsh_script_command.ZshScriptCompletionsCommand;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./bash-config-command.cjs`),t=require(`./bash-script-command.cjs`),n=require(`./bash-shared.cjs`),r=require(`./fish-config-command.cjs`),i=require(`./fish-script-command.cjs`),a=require(`./fish-shared.cjs`),o=require(`./powershell-config-command.cjs`),s=require(`./powershell-script-command.cjs`),c=require(`./powershell-shared.cjs`),l=require(`./zsh-config-command.cjs`),u=require(`./zsh-script-command.cjs`),d=require(`./zsh-shared.cjs`);exports.BashCompletionsShared=n.BashCompletionsShared,exports.BashConfigCompletionsCommand=e.BashConfigCompletionsCommand,exports.BashScriptCompletionsCommand=t.BashScriptCompletionsCommand,exports.FishCompletionsShared=a.FishCompletionsShared,exports.FishConfigCompletionsCommand=r.FishConfigCompletionsCommand,exports.FishScriptCompletionsCommand=i.FishScriptCompletionsCommand,exports.PowerShellCompletionsShared=c.PowerShellCompletionsShared,exports.PowerShellConfigCompletionsCommand=o.PowerShellConfigCompletionsCommand,exports.PowerShellScriptCompletionsCommand=s.PowerShellScriptCompletionsCommand,exports.ZshCompletionsShared=d.ZshCompletionsShared,exports.ZshConfigCompletionsCommand=l.ZshConfigCompletionsCommand,exports.ZshScriptCompletionsCommand=u.ZshScriptCompletionsCommand;
@@ -1,14 +1 @@
1
- import { BashConfigCompletionsCommand } from "./bash-config-command.mjs";
2
- import { BashScriptCompletionsCommand } from "./bash-script-command.mjs";
3
- import { BashCompletionsShared } from "./bash-shared.mjs";
4
- import { FishConfigCompletionsCommand } from "./fish-config-command.mjs";
5
- import { FishScriptCompletionsCommand } from "./fish-script-command.mjs";
6
- import { FishCompletionsShared } from "./fish-shared.mjs";
7
- import { PowerShellConfigCompletionsCommand } from "./powershell-config-command.mjs";
8
- import { PowerShellScriptCompletionsCommand } from "./powershell-script-command.mjs";
9
- import { PowerShellCompletionsShared } from "./powershell-shared.mjs";
10
- import { ZshConfigCompletionsCommand } from "./zsh-config-command.mjs";
11
- import { ZshScriptCompletionsCommand } from "./zsh-script-command.mjs";
12
- import { ZshCompletionsShared } from "./zsh-shared.mjs";
13
-
14
- export { BashCompletionsShared, BashConfigCompletionsCommand, BashScriptCompletionsCommand, FishCompletionsShared, FishConfigCompletionsCommand, FishScriptCompletionsCommand, PowerShellCompletionsShared, PowerShellConfigCompletionsCommand, PowerShellScriptCompletionsCommand, ZshCompletionsShared, ZshConfigCompletionsCommand, ZshScriptCompletionsCommand };
1
+ import{BashConfigCompletionsCommand as e}from"./bash-config-command.mjs";import{BashScriptCompletionsCommand as t}from"./bash-script-command.mjs";import{BashCompletionsShared as n}from"./bash-shared.mjs";import{FishConfigCompletionsCommand as r}from"./fish-config-command.mjs";import{FishScriptCompletionsCommand as i}from"./fish-script-command.mjs";import{FishCompletionsShared as a}from"./fish-shared.mjs";import{PowerShellConfigCompletionsCommand as o}from"./powershell-config-command.mjs";import{PowerShellScriptCompletionsCommand as s}from"./powershell-script-command.mjs";import{PowerShellCompletionsShared as c}from"./powershell-shared.mjs";import{ZshConfigCompletionsCommand as l}from"./zsh-config-command.mjs";import{ZshScriptCompletionsCommand as u}from"./zsh-script-command.mjs";import{ZshCompletionsShared as d}from"./zsh-shared.mjs";export{n as BashCompletionsShared,e as BashConfigCompletionsCommand,t as BashScriptCompletionsCommand,a as FishCompletionsShared,r as FishConfigCompletionsCommand,i as FishScriptCompletionsCommand,c as PowerShellCompletionsShared,o as PowerShellConfigCompletionsCommand,s as PowerShellScriptCompletionsCommand,d as ZshCompletionsShared,l as ZshConfigCompletionsCommand,u as ZshScriptCompletionsCommand};