@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.
@@ -3,7 +3,6 @@ const require_helpers_complete_command = require('../helpers/complete-command.cj
3
3
  const require_helpers_completion_directive_constants = require('../helpers/completion-directive-constants.cjs');
4
4
  let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
5
  let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
6
- let _stryke_path = require("@stryke/path");
7
6
  let _alloy_js_core = require("@alloy-js/core");
8
7
  let _alloy_js_typescript = require("@alloy-js/typescript");
9
8
  let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
@@ -11,6 +10,7 @@ let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
11
10
  let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
12
11
  let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
13
12
  let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
13
+ let _stryke_path = require("@stryke/path");
14
14
  let _stryke_string_format_snake_case = require("@stryke/string-format/snake-case");
15
15
 
16
16
  //#region src/components/fish-command.tsx
@@ -19,12 +19,15 @@ let _stryke_string_format_snake_case = require("@stryke/string-format/snake-case
19
19
  */
20
20
  function FishCompletionsCommand() {
21
21
  const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
22
+ const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
23
+ const name = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_snake_case.snakeCase)(bin.value));
22
24
  return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
23
25
  get path() {
24
26
  return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "fish", "command.ts");
25
27
  },
26
28
  imports: {
27
- "node:os": ["os"],
29
+ "node:os": "os",
30
+ "node:path": ["join"],
28
31
  "node:fs/promises": ["readFile", "writeFile"]
29
32
  },
30
33
  builtinImports: { "shell-shock:console": [
@@ -50,7 +53,7 @@ function FishCompletionsCommand() {
50
53
  return _powerlines_deepkit_vendor_type.ReflectionKind.string;
51
54
  },
52
55
  get defaultValue() {
53
- return `${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}-completions.fish`;
56
+ return `${bin.value}-completions.fish`;
54
57
  }
55
58
  })];
56
59
  }
@@ -98,30 +101,30 @@ function FishCompletionsCommand() {
98
101
  name: "completions",
99
102
  type: "string",
100
103
  get initializer() {
101
- return _alloy_js_core.code`# fish completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} -*- shell-script -*-
104
+ return _alloy_js_core.code` \`# fish completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} -*- shell-script -*-
102
105
 
103
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug
106
+ function __${name.value}_debug
104
107
  set -l file "$BASH_COMP_DEBUG_FILE"
105
108
  if test -n "$file"
106
109
  echo "$argv" >> $file
107
110
  end
108
111
  end
109
112
 
110
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion
111
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Starting __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion"
113
+ function __${name.value}_perform_completion
114
+ __${name.value}_debug "Starting __${name.value}_perform_completion"
112
115
 
113
116
  # Extract all args except the last one
114
117
  set -l args (commandline -opc)
115
118
  # Extract the last arg and escape it in case it is a space or wildcard
116
119
  set -l lastArg (string escape -- (commandline -ct))
117
120
 
118
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "args: $args"
119
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "last arg: $lastArg"
121
+ __${name.value}_debug "args: $args"
122
+ __${name.value}_debug "last arg: $lastArg"
120
123
 
121
124
  # Build the completion request command
122
- set -l requestComp "${require_helpers_complete_command.exec} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
125
+ set -l requestComp "${require_helpers_complete_command.EXEC_COMMAND} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
123
126
 
124
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Calling $requestComp"
127
+ __${name.value}_debug "Calling $requestComp"
125
128
  set -l results (eval $requestComp 2> /dev/null)
126
129
 
127
130
  # Some programs may output extra empty lines after the directive.
@@ -144,9 +147,9 @@ function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_co
144
147
  # completions must be prefixed with the flag
145
148
  set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
146
149
 
147
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Comps: $comps"
148
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "DirectiveLine: $directiveLine"
149
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "flagPrefix: $flagPrefix"
150
+ __${name.value}_debug "Comps: $comps"
151
+ __${name.value}_debug "DirectiveLine: $directiveLine"
152
+ __${name.value}_debug "flagPrefix: $flagPrefix"
150
153
 
151
154
  for comp in $comps
152
155
  printf "%s%s\\n" "$flagPrefix" "$comp"
@@ -155,83 +158,84 @@ function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_co
155
158
  printf "%s\\n" "$directiveLine"
156
159
  end
157
160
 
158
- # This function limits calls to __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion, by caching the result
159
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once
160
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Starting __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once"
161
+ # This function limits calls to __${name.value}_perform_completion, by caching the result
162
+ function __${name.value}_perform_completion_once
163
+ __${name.value}_debug "Starting __${name.value}_perform_completion_once"
161
164
 
162
- if test -n "$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
163
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Seems like a valid result already exists, skipping __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion"
165
+ if test -n "$__${name.value}_perform_completion_once_result"
166
+ __${name.value}_debug "Seems like a valid result already exists, skipping __${name.value}_perform_completion"
164
167
  return 0
165
168
  end
166
169
 
167
- set --global __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result (__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion)
168
- if test -z "$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
169
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "No completions, probably due to a failure"
170
+ set --global __${name.value}_perform_completion_once_result (__${name.value}_perform_completion)
171
+ if test -z "$__${name.value}_perform_completion_once_result"
172
+ __${name.value}_debug "No completions, probably due to a failure"
170
173
  return 1
171
174
  end
172
175
 
173
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Performed completions and set __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
176
+ __${name.value}_debug "Performed completions and set __${name.value}_perform_completion_once_result"
174
177
  return 0
175
178
  end
176
179
 
177
180
  # This function is used to clear the cached result after completions are run
178
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_clear_perform_completion_once_result
179
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug ""
180
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "========= clearing previously set __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result variable =========="
181
- set --erase __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result
182
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Successfully erased the variable __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
181
+ function __${name.value}_clear_perform_completion_once_result
182
+ __${name.value}_debug ""
183
+ __${name.value}_debug "========= clearing previously set __${name.value}_perform_completion_once_result variable =========="
184
+ set --erase __${name.value}_perform_completion_once_result
185
+ __${name.value}_debug "Successfully erased the variable __${name.value}_perform_completion_once_result"
183
186
  end
184
187
 
185
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_requires_order_preservation
186
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug ""
187
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "========= checking if order preservation is required =========="
188
+ function __${name.value}_requires_order_preservation
189
+ __${name.value}_debug ""
190
+ __${name.value}_debug "========= checking if order preservation is required =========="
188
191
 
189
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once
190
- if test -z "$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
191
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Error determining if order preservation is required"
192
+ __${name.value}_perform_completion_once
193
+ if test -z "$__${name.value}_perform_completion_once_result"
194
+ __${name.value}_debug "Error determining if order preservation is required"
192
195
  return 1
193
196
  end
194
197
 
195
- set -l directive (string sub --start 2 $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result[-1])
196
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Directive is: $directive"
198
+ set -l directive (string sub --start 2 $__$
199
+ {name.value}_perform_completion_once_result[-1])
200
+ __${name.value}_debug "Directive is: $directive"
197
201
 
198
202
  set -l shellCompDirectiveKeepOrder ${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
199
203
  set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
200
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Keeporder is: $keeporder"
204
+ __${name.value}_debug "Keeporder is: $keeporder"
201
205
 
202
206
  if test $keeporder -ne 0
203
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "This does require order preservation"
207
+ __${name.value}_debug "This does require order preservation"
204
208
  return 0
205
209
  end
206
210
 
207
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "This doesn't require order preservation"
211
+ __${name.value}_debug "This doesn't require order preservation"
208
212
  return 1
209
213
  end
210
214
 
211
215
  # This function does two things:
212
- # - Obtain the completions and store them in the global __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results
216
+ # - Obtain the completions and store them in the global __${name.value}_comp_results
213
217
  # - Return false if file completion should be performed
214
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_prepare_completions
215
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug ""
216
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "========= starting completion logic =========="
218
+ function __${name.value}_prepare_completions
219
+ __${name.value}_debug ""
220
+ __${name.value}_debug "========= starting completion logic =========="
217
221
 
218
222
  # Start fresh
219
- set --erase __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results
223
+ set --erase __${name.value}_comp_results
220
224
 
221
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once
222
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Completion results: $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
225
+ __${name.value}_perform_completion_once
226
+ __${name.value}_debug "Completion results: $__${name.value}_perform_completion_once_result"
223
227
 
224
- if test -z "$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
225
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "No completion, probably due to a failure"
228
+ if test -z "$__${name.value}_perform_completion_once_result"
229
+ __${name.value}_debug "No completion, probably due to a failure"
226
230
  # Might as well do file completion, in case it helps
227
231
  return 1
228
232
  end
229
233
 
230
- set -l directive (string sub --start 2 $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result[-1])
231
- set --global __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result[1..-2]
234
+ set -l directive (string sub --start 2 $__${name.value}_perform_completion_once_result[-1])
235
+ set --global __${name.value}_comp_results $__${name.value}_perform_completion_once_result[1..-2]
232
236
 
233
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Completions are: $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results"
234
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Directive is: $directive"
237
+ __${name.value}_debug "Completions are: $__${name.value}_comp_results"
238
+ __${name.value}_debug "Directive is: $directive"
235
239
 
236
240
  set -l shellCompDirectiveError ${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
237
241
  set -l shellCompDirectiveNoSpace ${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
@@ -244,7 +248,7 @@ function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_co
244
248
 
245
249
  set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
246
250
  if test $compErr -eq 1
247
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Received error directive: aborting."
251
+ __${name.value}_debug "Received error directive: aborting."
248
252
  # Might as well do file completion, in case it helps
249
253
  return 1
250
254
  end
@@ -252,7 +256,7 @@ function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_co
252
256
  set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
253
257
  set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
254
258
  if test $filefilter -eq 1; or test $dirfilter -eq 1
255
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "File extension filtering or directory filtering not supported"
259
+ __${name.value}_debug "File extension filtering or directory filtering not supported"
256
260
  # Do full file completion instead
257
261
  return 1
258
262
  end
@@ -260,7 +264,7 @@ function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_co
260
264
  set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
261
265
  set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
262
266
 
263
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "nospace: $nospace, nofiles: $nofiles"
267
+ __${name.value}_debug "nospace: $nospace, nofiles: $nofiles"
264
268
 
265
269
  # If we want to prevent a space, or if file completion is NOT disabled,
266
270
  # we need to count the number of valid completions.
@@ -269,22 +273,22 @@ function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_co
269
273
  # criteria than the prefix.
270
274
  if test $nospace -ne 0; or test $nofiles -eq 0
271
275
  set -l prefix (commandline -t | string escape --style=regex)
272
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "prefix: $prefix"
276
+ __${name.value}_debug "prefix: $prefix"
273
277
 
274
- set -l completions (string match -r -- "^$prefix.*" $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results)
275
- set --global __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results $completions
276
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Filtered completions are: $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results"
278
+ set -l completions (string match -r -- "^$prefix.*" $__${name.value}_comp_results)
279
+ set --global __${name.value}_comp_results $completions
280
+ __${name.value}_debug "Filtered completions are: $__${name.value}_comp_results"
277
281
 
278
282
  # Important not to quote the variable for count to work
279
- set -l numComps (count $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results)
280
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "numComps: $numComps"
283
+ set -l numComps (count $__${name.value}_comp_results)
284
+ __${name.value}_debug "numComps: $numComps"
281
285
 
282
286
  if test $numComps -eq 1; and test $nospace -ne 0
283
287
  # We must first split on \\t to get rid of the descriptions to be
284
288
  # able to check what the actual completion will be.
285
289
  # We don't need descriptions anyway since there is only a single
286
290
  # real completion which the shell will expand immediately.
287
- set -l split (string split --max 1 "\\t" $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results[1])
291
+ set -l split (string split --max 1 "\\t" $__${name.value}_comp_results[1])
288
292
 
289
293
  # Fish won't add a space if the completion ends with any
290
294
  # of the following characters: @=/:.,
@@ -292,16 +296,16 @@ function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_co
292
296
  if not string match -r -q "[@=/:.,]" -- "$lastChar"
293
297
  # In other cases, to support the "nospace" directive we trick the shell
294
298
  # by outputting an extra, longer completion.
295
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding second completion to perform nospace directive"
296
- set --global __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results $split[1] $split[1].
297
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Completions are now: $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results"
299
+ __${name.value}_debug "Adding second completion to perform nospace directive"
300
+ set --global __${name.value}_comp_results $split[1] $split[1].
301
+ __${name.value}_debug "Completions are now: $__${name.value}_comp_results"
298
302
  end
299
303
  end
300
304
 
301
305
  if test $numComps -eq 0; and test $nofiles -eq 0
302
306
  # To be consistent with bash and zsh, we only trigger file
303
307
  # completion when there are no other completions
304
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Requesting file completion"
308
+ __${name.value}_debug "Requesting file completion"
305
309
  return 1
306
310
  end
307
311
  end
@@ -313,24 +317,24 @@ end
313
317
  # so we can properly delete any completions provided by another script.
314
318
  # Only do this if the program can be found, or else fish may print some errors; besides,
315
319
  # the existing completions will only be loaded if the program can be found.
316
- if type -q "${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}"
320
+ if type -q "${bin.value}"
317
321
  # The space after the program name is essential to trigger completion for the program
318
322
  # and not completion of the program name itself.
319
323
  # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
320
- complete --do-complete "${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} " > /dev/null 2>&1
324
+ complete --do-complete "${bin.value} " > /dev/null 2>&1
321
325
  end
322
326
 
323
327
  # Remove any pre-existing completions for the program since we will be handling all of them.
324
- complete -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -e
328
+ complete -c ${bin.value} -e
325
329
  # This will get called after the two calls below and clear the cached result
326
- complete -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n '__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_clear_perform_completion_once_result'
327
- # The call to __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_prepare_completions will setup __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results
330
+ complete -c ${bin.value} -n '__${name.value}_clear_perform_completion_once_result'
331
+ # The call to __${name.value}_prepare_completions will setup __${name.value}_comp_results
328
332
  # which provides the program's completion choices.
329
333
  # If this doesn't require order preservation, we don't use the -k flag
330
- complete -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n 'not __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_requires_order_preservation && __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_prepare_completions' -f -a '$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results'
334
+ complete -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n 'not __${name.value}_requires_order_preservation && __${name.value}_prepare_completions' -f -a '$__${name.value}_comp_results'
331
335
  # Otherwise we use the -k flag
332
- complete -k -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n '__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_requires_order_preservation && __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_prepare_completions' -f -a '$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results'
333
- \`);`;
336
+ complete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && __${name.value}_prepare_completions' -f -a '$__${name.value}_comp_results'
337
+ \`; `;
334
338
  }
335
339
  }),
336
340
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
@@ -360,7 +364,7 @@ complete -k -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n '__$
360
364
  (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
361
365
  configFileContent = await readFile(configFilePath, "utf8");
362
366
  } catch (error) {
363
- if (error.code === "ENOENT") {
367
+ if (Error.isError(error) && error.code === "ENOENT") {
364
368
  // If the file doesn't exist, we can create it later when writing the completion script.
365
369
  warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
366
370
  } else {
@@ -378,7 +382,7 @@ complete -k -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n '__$
378
382
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
379
383
  condition: _alloy_js_core.code`options.script`,
380
384
  get children() {
381
- return _alloy_js_core.code`const outputPath = options.script === true ? "${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}-completions.fish" : options.script;
385
+ return _alloy_js_core.code`const outputPath = options.script === true ? "${bin.value}-completions.fish" : options.script;
382
386
  await writeFile(outputPath, stripAnsi(completions));
383
387
 
384
388
  success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish completion script has been generated at \${colors.bold(outputPath)}.\`);`;