@shell-shock/plugin-completions 0.1.13 → 0.2.0

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 (66) hide show
  1. package/dist/components/bash-command.cjs +101 -25
  2. package/dist/components/bash-command.d.cts +2 -2
  3. package/dist/components/bash-command.d.cts.map +1 -1
  4. package/dist/components/bash-command.d.mts +2 -2
  5. package/dist/components/bash-command.d.mts.map +1 -1
  6. package/dist/components/bash-command.mjs +101 -25
  7. package/dist/components/bash-command.mjs.map +1 -1
  8. package/dist/components/fish-command.cjs +402 -0
  9. package/dist/components/fish-command.d.cts +10 -0
  10. package/dist/components/fish-command.d.cts.map +1 -0
  11. package/dist/components/fish-command.d.mts +10 -0
  12. package/dist/components/fish-command.d.mts.map +1 -0
  13. package/dist/components/fish-command.mjs +403 -0
  14. package/dist/components/fish-command.mjs.map +1 -0
  15. package/dist/components/index.cjs +4 -0
  16. package/dist/components/index.d.cts +3 -1
  17. package/dist/components/index.d.mts +3 -1
  18. package/dist/components/index.mjs +3 -1
  19. package/dist/components/powershell-command.cjs +418 -0
  20. package/dist/components/powershell-command.d.cts +10 -0
  21. package/dist/components/powershell-command.d.cts.map +1 -0
  22. package/dist/components/powershell-command.d.mts +10 -0
  23. package/dist/components/powershell-command.d.mts.map +1 -0
  24. package/dist/components/powershell-command.mjs +419 -0
  25. package/dist/components/powershell-command.mjs.map +1 -0
  26. package/dist/components/zsh-command.cjs +213 -26
  27. package/dist/components/zsh-command.d.cts.map +1 -1
  28. package/dist/components/zsh-command.d.mts +2 -2
  29. package/dist/components/zsh-command.d.mts.map +1 -1
  30. package/dist/components/zsh-command.mjs +213 -26
  31. package/dist/components/zsh-command.mjs.map +1 -1
  32. package/dist/helpers/complete-command.cjs +14 -0
  33. package/dist/helpers/complete-command.d.cts +5 -0
  34. package/dist/helpers/complete-command.d.cts.map +1 -0
  35. package/dist/helpers/complete-command.d.mts +5 -0
  36. package/dist/helpers/complete-command.d.mts.map +1 -0
  37. package/dist/helpers/complete-command.mjs +14 -0
  38. package/dist/helpers/complete-command.mjs.map +1 -0
  39. package/dist/helpers/completion-directive-constants.cjs +15 -0
  40. package/dist/helpers/completion-directive-constants.d.cts +14 -0
  41. package/dist/helpers/completion-directive-constants.d.cts.map +1 -0
  42. package/dist/helpers/completion-directive-constants.d.mts +14 -0
  43. package/dist/helpers/completion-directive-constants.d.mts.map +1 -0
  44. package/dist/helpers/completion-directive-constants.mjs +15 -0
  45. package/dist/helpers/completion-directive-constants.mjs.map +1 -0
  46. package/dist/helpers/index.cjs +5 -0
  47. package/dist/helpers/index.d.cts +3 -0
  48. package/dist/helpers/index.d.mts +3 -0
  49. package/dist/helpers/index.mjs +4 -0
  50. package/dist/index.cjs +42 -5
  51. package/dist/index.d.cts.map +1 -1
  52. package/dist/index.d.mts.map +1 -1
  53. package/dist/index.mjs +42 -5
  54. package/dist/index.mjs.map +1 -1
  55. package/dist/types/index.d.cts +1 -1
  56. package/dist/types/index.d.mts +1 -1
  57. package/dist/types/plugin.d.cts +16 -3
  58. package/dist/types/plugin.d.cts.map +1 -1
  59. package/dist/types/plugin.d.mts +16 -3
  60. package/dist/types/plugin.d.mts.map +1 -1
  61. package/dist/types/shell-type.cjs +6 -1
  62. package/dist/types/shell-type.d.cts +1 -1
  63. package/dist/types/shell-type.d.mts +1 -1
  64. package/dist/types/shell-type.mjs +6 -1
  65. package/dist/types/shell-type.mjs.map +1 -1
  66. package/package.json +79 -8
@@ -1,3 +1,5 @@
1
+ const require_helpers_complete_command = require('../helpers/complete-command.cjs');
2
+ const require_helpers_completion_directive_constants = require('../helpers/completion-directive-constants.cjs');
1
3
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
2
4
  let __shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
3
5
  let __stryke_path = require("@stryke/path");
@@ -8,6 +10,7 @@ let __powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
8
10
  let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
9
11
  let __powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
10
12
  let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
13
+ let __stryke_string_format = require("@stryke/string-format");
11
14
 
12
15
  //#region src/components/zsh-command.tsx
13
16
  /**
@@ -94,35 +97,219 @@ function ZshCompletionsCommand() {
94
97
  name: "completions",
95
98
  type: "string",
96
99
  get initializer() {
97
- return __alloy_js_core.code`colors.white(\`\${colors.gray(\`#compdef \${colors.bold("${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}")}\`)}
98
- \${colors.gray("###-begin-${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}-completions-###")}
99
-
100
- \${colors.gray(\`
101
- # \${colors.bold("${(0, __shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh CLI command completion script")}
102
- #
103
- # \${colors.bold("Installation:")} ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} completions zsh --config ~/.zshrc or ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} completions zsh --script or ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} completions zsh >> ~/.zshrc or ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} completions zsh >> ~/.zprofile on OSX. \`
104
- )}
105
- \${colors.cyan("_${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}_completions()")}
106
- {
107
- local reply
108
- local si=$IFS
109
- IFS=$'\\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} --get-completions "\\\${words[@]}"))
110
- IFS=$si
111
- if [[ \\\${#reply} -gt 0 ]]; then
112
- _describe 'values' reply
113
- else
114
- _default
115
- fi
100
+ return __alloy_js_core.code`#compdef ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}
101
+ compdef _${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))} ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}
102
+
103
+ # zsh completion for ${(0, __shell_shock_core_plugin_utils.getAppTitle)(context)} -*- shell-script -*-
104
+
105
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug() {
106
+ local file="$BASH_COMP_DEBUG_FILE"
107
+ if [[ -n \${file} ]]; then
108
+ echo "$*" >> "\${file}"
109
+ fi
116
110
  }
117
111
 
118
- if [[ "\\\${zsh_eval_context[-1]}" == "loadautofunc" ]]; then
119
- _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}_completions "$@"
120
- else
121
- compdef _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}_completions ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}
122
- fi
123
- complete -o bashdefault -o default -F _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}_completions ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}
112
+ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
113
+ local shellCompDirectiveError=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
114
+ local shellCompDirectiveNoSpace=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
115
+ local shellCompDirectiveNoFileComp=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoFileComp}
116
+ local shellCompDirectiveFilterFileExt=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterFileExt}
117
+ local shellCompDirectiveFilterDirs=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterDirs}
118
+ local shellCompDirectiveKeepOrder=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
119
+
120
+ local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
121
+ local -a completions
122
+
123
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "\\n========= starting completion logic =========="
124
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
125
+
126
+ # The user could have moved the cursor backwards on the command-line.
127
+ # We need to trigger completion from the $CURRENT location, so we need
128
+ # to truncate the command-line ($words) up to the $CURRENT location.
129
+ # (We cannot use $CURSOR as its value does not work when a command is an alias.)
130
+ words=( "\${=words[1,CURRENT]}" )
131
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Truncated words[*]: \${words[*]},"
132
+
133
+ lastParam=\${words[-1]}
134
+ lastChar=\${lastParam[-1]}
135
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
136
+ # For zsh, when completing a flag with an = (e.g., ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} -n=<TAB>)
137
+ # completions must be prefixed with the flag
138
+ setopt local_options BASH_REMATCH
139
+ if [[ "\${lastParam}" =~ '-.*=' ]]; then
140
+ # We are dealing with a flag with an =
141
+ flagPrefix="-P \${BASH_REMATCH}"
142
+ fi
143
+
144
+ # Prepare the command to obtain completions, ensuring arguments are quoted for eval
145
+ local -a args_to_quote=("\${(@)words[2,-1]}")
146
+ if [ "\${lastChar}" = "" ]; then
147
+ # If the last parameter is complete (there is a space following it)
148
+ # We add an extra empty parameter so we can indicate this to the go completion code.
149
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding extra empty parameter"
150
+ args_to_quote+=("")
151
+ fi
152
+
153
+ # Use Zsh's (q) flag to quote each argument safely for eval
154
+ local quoted_args=("\${(@q)args_to_quote}")
155
+
156
+ # Join the main command and the quoted arguments into a single string for eval
157
+ requestComp="${require_helpers_complete_command.exec} complete -- \${quoted_args[*]}"
158
+
159
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "About to call: eval \${requestComp}"
160
+
161
+ # Use eval to handle any environment variables and such
162
+ out=$(eval \${requestComp} 2>/dev/null)
163
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "completion output: \${out}"
164
+
165
+ # Extract the directive integer following a : from the last line
166
+ local lastLine
167
+ while IFS='\n' read -r line; do
168
+ lastLine=\${line}
169
+ done < <(printf "%s\n" "\${out[@]}")
170
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "last line: \${lastLine}"
171
+
172
+ if [ "\${lastLine[1]}" = : ]; then
173
+ directive=\${lastLine[2,-1]}
174
+ # Remove the directive including the : and the newline
175
+ local suffix
176
+ (( suffix=\${#lastLine}+2))
177
+ out=\${out[1,-$suffix]}
178
+ else
179
+ # There is no directive specified. Leave $out as is.
180
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "No directive found. Setting to default"
181
+ directive=0
182
+ fi
183
+
184
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "directive: \${directive}"
185
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "completions: \${out}"
186
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "flagPrefix: \${flagPrefix}"
187
+
188
+ if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
189
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Completion received error. Ignoring completions."
190
+ return
191
+ fi
124
192
 
125
- \${colors.gray("###-end-${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}-completions-###")}
193
+ local activeHelpMarker="%"
194
+ local endIndex=\${#activeHelpMarker}
195
+ local startIndex=$((\${#activeHelpMarker}+1))
196
+ local hasActiveHelp=0
197
+ while IFS='\n' read -r comp; do
198
+ # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
199
+ if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
200
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "ActiveHelp found: $comp"
201
+ comp="\${comp[$startIndex,-1]}"
202
+ if [ -n "$comp" ]; then
203
+ compadd -x "\${comp}"
204
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "ActiveHelp will need delimiter"
205
+ hasActiveHelp=1
206
+ fi
207
+ continue
208
+ fi
209
+
210
+ if [ -n "$comp" ]; then
211
+ # If requested, completions are returned with a description.
212
+ # The description is preceded by a TAB character.
213
+ # For zsh's _describe, we need to use a : instead of a TAB.
214
+ # We first need to escape any : as part of the completion itself.
215
+ comp=\${comp//:/\\:}
216
+
217
+ local tab="$(printf '\\t')"
218
+ comp=\${comp//$tab/:}
219
+
220
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding completion: \${comp}"
221
+ completions+=\${comp}
222
+ lastComp=$comp
223
+ fi
224
+ done < <(printf "%s\n" "\${out[@]}")
225
+
226
+ # Add a delimiter after the activeHelp statements, but only if:
227
+ # - there are completions following the activeHelp statements, or
228
+ # - file completion will be performed (so there will be choices after the activeHelp)
229
+ if [ $hasActiveHelp -eq 1 ]; then
230
+ if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
231
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding activeHelp delimiter"
232
+ compadd -x "--"
233
+ hasActiveHelp=0
234
+ fi
235
+ fi
236
+
237
+ if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
238
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating nospace."
239
+ noSpace="-S ''"
240
+ fi
241
+
242
+ if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
243
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating keep order."
244
+ keepOrder="-V"
245
+ fi
246
+
247
+ if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
248
+ # File extension filtering
249
+ local filteringCmd
250
+ filteringCmd='_files'
251
+ for filter in \${completions[@]}; do
252
+ if [ \${filter[1]} != '*' ]; then
253
+ # zsh requires a glob pattern to do file filtering
254
+ filter="\\*.$filter"
255
+ fi
256
+ filteringCmd+=" -g $filter"
257
+ done
258
+ filteringCmd+=" \${flagPrefix}"
259
+
260
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "File filtering command: $filteringCmd"
261
+ _arguments '*:filename:'"$filteringCmd"
262
+ elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
263
+ # File completion for directories only
264
+ local subdir
265
+ subdir="\${completions[1]}"
266
+ if [ -n "$subdir" ]; then
267
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Listing directories in $subdir"
268
+ pushd "\${subdir}" >/dev/null 2>&1
269
+ else
270
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Listing directories in ."
271
+ fi
272
+
273
+ local result
274
+ _arguments '*:dirname:_files -/'" \${flagPrefix}"
275
+ result=$?
276
+ if [ -n "$subdir" ]; then
277
+ popd >/dev/null 2>&1
278
+ fi
279
+ return $result
280
+ else
281
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Calling _describe"
282
+ if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
283
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "_describe found some completions"
284
+
285
+ # Return the success of having called _describe
286
+ return 0
287
+ else
288
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "_describe did not find completions."
289
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Checking if we should do file completion."
290
+ if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
291
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "deactivating file completion"
292
+
293
+ # Return 0 to indicate completion is finished and prevent zsh from
294
+ # trying other completion algorithms (which could cause hanging).
295
+ # We use NoFileComp directive to explicitly disable file completion.
296
+ return 0
297
+ else
298
+ # Perform file completion
299
+ __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating file completion"
300
+
301
+ # We must return the result of this command, so it must be the
302
+ # last command, or else we must store its result to return it.
303
+ _arguments '*:filename:_files'" \${flagPrefix}"
304
+ fi
305
+ fi
306
+ fi
307
+ }
308
+
309
+ # don't run the completion function when being sourced or eval-ed
310
+ if [ "\${funcstack[1]}" = "_${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}" ]; then
311
+ _${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}
312
+ fi
126
313
  \`);`;
127
314
  }
128
315
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"zsh-command.d.cts","names":[],"sources":["../../src/components/zsh-command.tsx"],"sourcesContent":[],"mappings":";;;;;;AA4CgB,iBAAA,qBAAA,CAAA,CAAqB,EAAA,eAAA,CAAA,QAAA"}
1
+ {"version":3,"file":"zsh-command.d.cts","names":[],"sources":["../../src/components/zsh-command.tsx"],"sourcesContent":[],"mappings":";;;;;;AA+CgB,iBAAA,qBAAA,CAAA,CAAqB,EAAA,eAAA,CAAA,QAAA"}
@@ -1,10 +1,10 @@
1
- import * as _alloy_js_core0 from "@alloy-js/core";
1
+ import * as _alloy_js_core2 from "@alloy-js/core";
2
2
 
3
3
  //#region src/components/zsh-command.d.ts
4
4
  /**
5
5
  * The Zsh Completions commands' handler wrapper for the Shell Shock project.
6
6
  */
7
- declare function ZshCompletionsCommand(): _alloy_js_core0.Children;
7
+ declare function ZshCompletionsCommand(): _alloy_js_core2.Children;
8
8
  //#endregion
9
9
  export { ZshCompletionsCommand };
10
10
  //# sourceMappingURL=zsh-command.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zsh-command.d.mts","names":[],"sources":["../../src/components/zsh-command.tsx"],"sourcesContent":[],"mappings":";;;;;;AA4CgB,iBAAA,qBAAA,CAAA,CAAqB,EAAA,eAAA,CAAA,QAAA"}
1
+ {"version":3,"file":"zsh-command.d.mts","names":[],"sources":["../../src/components/zsh-command.tsx"],"sourcesContent":[],"mappings":";;;;;;AA+CgB,iBAAA,qBAAA,CAAA,CAAqB,EAAA,eAAA,CAAA,QAAA"}
@@ -1,3 +1,5 @@
1
+ import { exec } from "../helpers/complete-command.mjs";
2
+ import { CompletionDirective } from "../helpers/completion-directive-constants.mjs";
1
3
  import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
2
4
  import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
3
5
  import { joinPaths } from "@stryke/path";
@@ -8,6 +10,7 @@ import { Spacing } from "@powerlines/plugin-alloy/core";
8
10
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
9
11
  import { InterfaceMember, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
10
12
  import { TSDoc, TSDocDefaultValue, TSDocRemarks } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
13
+ import { snakeCase } from "@stryke/string-format";
11
14
 
12
15
  //#region src/components/zsh-command.tsx
13
16
  /**
@@ -94,35 +97,219 @@ function ZshCompletionsCommand() {
94
97
  name: "completions",
95
98
  type: "string",
96
99
  get initializer() {
97
- return code`colors.white(\`\${colors.gray(\`#compdef \${colors.bold("${getAppBin(context)}")}\`)}
98
- \${colors.gray("###-begin-${getAppBin(context)}-completions-###")}
99
-
100
- \${colors.gray(\`
101
- # \${colors.bold("${getAppTitle(context)} Zsh CLI command completion script")}
102
- #
103
- # \${colors.bold("Installation:")} ${getAppBin(context)} completions zsh --config ~/.zshrc or ${getAppBin(context)} completions zsh --script or ${getAppBin(context)} completions zsh >> ~/.zshrc or ${getAppBin(context)} completions zsh >> ~/.zprofile on OSX. \`
104
- )}
105
- \${colors.cyan("_${getAppBin(context)}_completions()")}
106
- {
107
- local reply
108
- local si=$IFS
109
- IFS=$'\\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" ${getAppBin(context)} --get-completions "\\\${words[@]}"))
110
- IFS=$si
111
- if [[ \\\${#reply} -gt 0 ]]; then
112
- _describe 'values' reply
113
- else
114
- _default
115
- fi
100
+ return code`#compdef ${getAppBin(context)}
101
+ compdef _${snakeCase(getAppBin(context))} ${getAppBin(context)}
102
+
103
+ # zsh completion for ${getAppTitle(context)} -*- shell-script -*-
104
+
105
+ __${snakeCase(getAppBin(context))}_debug() {
106
+ local file="$BASH_COMP_DEBUG_FILE"
107
+ if [[ -n \${file} ]]; then
108
+ echo "$*" >> "\${file}"
109
+ fi
116
110
  }
117
111
 
118
- if [[ "\\\${zsh_eval_context[-1]}" == "loadautofunc" ]]; then
119
- _${getAppBin(context)}_completions "$@"
120
- else
121
- compdef _${getAppBin(context)}_completions ${getAppBin(context)}
122
- fi
123
- complete -o bashdefault -o default -F _${getAppBin(context)}_completions ${getAppBin(context)}
112
+ _${getAppBin(context)}() {
113
+ local shellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}
114
+ local shellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}
115
+ local shellCompDirectiveNoFileComp=${CompletionDirective.CompletionDirectiveNoFileComp}
116
+ local shellCompDirectiveFilterFileExt=${CompletionDirective.CompletionDirectiveFilterFileExt}
117
+ local shellCompDirectiveFilterDirs=${CompletionDirective.CompletionDirectiveFilterDirs}
118
+ local shellCompDirectiveKeepOrder=${CompletionDirective.CompletionDirectiveKeepOrder}
119
+
120
+ local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
121
+ local -a completions
122
+
123
+ __${snakeCase(getAppBin(context))}_debug "\\n========= starting completion logic =========="
124
+ __${snakeCase(getAppBin(context))}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
125
+
126
+ # The user could have moved the cursor backwards on the command-line.
127
+ # We need to trigger completion from the $CURRENT location, so we need
128
+ # to truncate the command-line ($words) up to the $CURRENT location.
129
+ # (We cannot use $CURSOR as its value does not work when a command is an alias.)
130
+ words=( "\${=words[1,CURRENT]}" )
131
+ __${snakeCase(getAppBin(context))}_debug "Truncated words[*]: \${words[*]},"
132
+
133
+ lastParam=\${words[-1]}
134
+ lastChar=\${lastParam[-1]}
135
+ __${snakeCase(getAppBin(context))}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
136
+ # For zsh, when completing a flag with an = (e.g., ${getAppBin(context)} -n=<TAB>)
137
+ # completions must be prefixed with the flag
138
+ setopt local_options BASH_REMATCH
139
+ if [[ "\${lastParam}" =~ '-.*=' ]]; then
140
+ # We are dealing with a flag with an =
141
+ flagPrefix="-P \${BASH_REMATCH}"
142
+ fi
143
+
144
+ # Prepare the command to obtain completions, ensuring arguments are quoted for eval
145
+ local -a args_to_quote=("\${(@)words[2,-1]}")
146
+ if [ "\${lastChar}" = "" ]; then
147
+ # If the last parameter is complete (there is a space following it)
148
+ # We add an extra empty parameter so we can indicate this to the go completion code.
149
+ __${snakeCase(getAppBin(context))}_debug "Adding extra empty parameter"
150
+ args_to_quote+=("")
151
+ fi
152
+
153
+ # Use Zsh's (q) flag to quote each argument safely for eval
154
+ local quoted_args=("\${(@q)args_to_quote}")
155
+
156
+ # Join the main command and the quoted arguments into a single string for eval
157
+ requestComp="${exec} complete -- \${quoted_args[*]}"
158
+
159
+ __${snakeCase(getAppBin(context))}_debug "About to call: eval \${requestComp}"
160
+
161
+ # Use eval to handle any environment variables and such
162
+ out=$(eval \${requestComp} 2>/dev/null)
163
+ __${snakeCase(getAppBin(context))}_debug "completion output: \${out}"
164
+
165
+ # Extract the directive integer following a : from the last line
166
+ local lastLine
167
+ while IFS='\n' read -r line; do
168
+ lastLine=\${line}
169
+ done < <(printf "%s\n" "\${out[@]}")
170
+ __${snakeCase(getAppBin(context))}_debug "last line: \${lastLine}"
171
+
172
+ if [ "\${lastLine[1]}" = : ]; then
173
+ directive=\${lastLine[2,-1]}
174
+ # Remove the directive including the : and the newline
175
+ local suffix
176
+ (( suffix=\${#lastLine}+2))
177
+ out=\${out[1,-$suffix]}
178
+ else
179
+ # There is no directive specified. Leave $out as is.
180
+ __${snakeCase(getAppBin(context))}_debug "No directive found. Setting to default"
181
+ directive=0
182
+ fi
183
+
184
+ __${snakeCase(getAppBin(context))}_debug "directive: \${directive}"
185
+ __${snakeCase(getAppBin(context))}_debug "completions: \${out}"
186
+ __${snakeCase(getAppBin(context))}_debug "flagPrefix: \${flagPrefix}"
187
+
188
+ if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
189
+ __${snakeCase(getAppBin(context))}_debug "Completion received error. Ignoring completions."
190
+ return
191
+ fi
124
192
 
125
- \${colors.gray("###-end-${getAppBin(context)}-completions-###")}
193
+ local activeHelpMarker="%"
194
+ local endIndex=\${#activeHelpMarker}
195
+ local startIndex=$((\${#activeHelpMarker}+1))
196
+ local hasActiveHelp=0
197
+ while IFS='\n' read -r comp; do
198
+ # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
199
+ if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
200
+ __${snakeCase(getAppBin(context))}_debug "ActiveHelp found: $comp"
201
+ comp="\${comp[$startIndex,-1]}"
202
+ if [ -n "$comp" ]; then
203
+ compadd -x "\${comp}"
204
+ __${snakeCase(getAppBin(context))}_debug "ActiveHelp will need delimiter"
205
+ hasActiveHelp=1
206
+ fi
207
+ continue
208
+ fi
209
+
210
+ if [ -n "$comp" ]; then
211
+ # If requested, completions are returned with a description.
212
+ # The description is preceded by a TAB character.
213
+ # For zsh's _describe, we need to use a : instead of a TAB.
214
+ # We first need to escape any : as part of the completion itself.
215
+ comp=\${comp//:/\\:}
216
+
217
+ local tab="$(printf '\\t')"
218
+ comp=\${comp//$tab/:}
219
+
220
+ __${snakeCase(getAppBin(context))}_debug "Adding completion: \${comp}"
221
+ completions+=\${comp}
222
+ lastComp=$comp
223
+ fi
224
+ done < <(printf "%s\n" "\${out[@]}")
225
+
226
+ # Add a delimiter after the activeHelp statements, but only if:
227
+ # - there are completions following the activeHelp statements, or
228
+ # - file completion will be performed (so there will be choices after the activeHelp)
229
+ if [ $hasActiveHelp -eq 1 ]; then
230
+ if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
231
+ __${snakeCase(getAppBin(context))}_debug "Adding activeHelp delimiter"
232
+ compadd -x "--"
233
+ hasActiveHelp=0
234
+ fi
235
+ fi
236
+
237
+ if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
238
+ __${snakeCase(getAppBin(context))}_debug "Activating nospace."
239
+ noSpace="-S ''"
240
+ fi
241
+
242
+ if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
243
+ __${snakeCase(getAppBin(context))}_debug "Activating keep order."
244
+ keepOrder="-V"
245
+ fi
246
+
247
+ if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
248
+ # File extension filtering
249
+ local filteringCmd
250
+ filteringCmd='_files'
251
+ for filter in \${completions[@]}; do
252
+ if [ \${filter[1]} != '*' ]; then
253
+ # zsh requires a glob pattern to do file filtering
254
+ filter="\\*.$filter"
255
+ fi
256
+ filteringCmd+=" -g $filter"
257
+ done
258
+ filteringCmd+=" \${flagPrefix}"
259
+
260
+ __${snakeCase(getAppBin(context))}_debug "File filtering command: $filteringCmd"
261
+ _arguments '*:filename:'"$filteringCmd"
262
+ elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
263
+ # File completion for directories only
264
+ local subdir
265
+ subdir="\${completions[1]}"
266
+ if [ -n "$subdir" ]; then
267
+ __${snakeCase(getAppBin(context))}_debug "Listing directories in $subdir"
268
+ pushd "\${subdir}" >/dev/null 2>&1
269
+ else
270
+ __${snakeCase(getAppBin(context))}_debug "Listing directories in ."
271
+ fi
272
+
273
+ local result
274
+ _arguments '*:dirname:_files -/'" \${flagPrefix}"
275
+ result=$?
276
+ if [ -n "$subdir" ]; then
277
+ popd >/dev/null 2>&1
278
+ fi
279
+ return $result
280
+ else
281
+ __${snakeCase(getAppBin(context))}_debug "Calling _describe"
282
+ if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
283
+ __${snakeCase(getAppBin(context))}_debug "_describe found some completions"
284
+
285
+ # Return the success of having called _describe
286
+ return 0
287
+ else
288
+ __${snakeCase(getAppBin(context))}_debug "_describe did not find completions."
289
+ __${snakeCase(getAppBin(context))}_debug "Checking if we should do file completion."
290
+ if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
291
+ __${snakeCase(getAppBin(context))}_debug "deactivating file completion"
292
+
293
+ # Return 0 to indicate completion is finished and prevent zsh from
294
+ # trying other completion algorithms (which could cause hanging).
295
+ # We use NoFileComp directive to explicitly disable file completion.
296
+ return 0
297
+ else
298
+ # Perform file completion
299
+ __${snakeCase(getAppBin(context))}_debug "Activating file completion"
300
+
301
+ # We must return the result of this command, so it must be the
302
+ # last command, or else we must store its result to return it.
303
+ _arguments '*:filename:_files'" \${flagPrefix}"
304
+ fi
305
+ fi
306
+ fi
307
+ }
308
+
309
+ # don't run the completion function when being sourced or eval-ed
310
+ if [ "\${funcstack[1]}" = "_${snakeCase(getAppBin(context))}" ]; then
311
+ _${snakeCase(getAppBin(context))}
312
+ fi
126
313
  \`);`;
127
314
  }
128
315
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"zsh-command.mjs","names":["code","FunctionDeclaration","IfStatement","InterfaceDeclaration","VarDeclaration","ReflectionKind","Spacing","usePowerlines","InterfaceMember","TypescriptFile","TSDoc","TSDocDefaultValue","TSDocRemarks","getAppBin","getAppTitle","joinPaths","ZshCompletionsCommand","context","_$createComponent","path","entryPath","imports","builtinImports","children","heading","name","type","string","defaultValue","optional","async","parameters","initializer","condition","_$memo"],"sources":["../../src/components/zsh-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 type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Zsh Completions commands' handler wrapper for the Shell Shock project.\n */\nexport function ZshCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(context.entryPath, \"completions\", \"zsh\", \"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 Zsh completions command.\" />\n <InterfaceDeclaration export name=\"ZshCompletionsOptions\">\n <TSDoc heading=\"The path to write the completion script to.\">\n <TSDocRemarks>{`If no extension is provided, the \\`.zsh\\` extension will be used.`}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue={`${getAppBin(context)}-completions.zsh`}\n />\n </TSDoc>\n <InterfaceMember name=\"script\" optional type=\"string | true\" />\n <Spacing />\n <TSDoc heading=\"The Zsh 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 Zsh configuration file include: \\\\n- \\`~/.zshrc\\` \\\\n- \\`~/.zprofile\\``}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue=\"~/.zshrc\"\n />\n </TSDoc>\n <InterfaceMember name=\"config\" optional type=\"string | true\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions zsh\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[{ name: \"options\", type: \"ZshCompletionsOptions\" }]}>\n <VarDeclaration\n const\n name=\"completions\"\n type=\"string\"\n initializer={code`colors.white(\\`\\${colors.gray(\\`#compdef \\${colors.bold(\"${getAppBin(context)}\")}\\`)}\n\\${colors.gray(\"###-begin-${getAppBin(context)}-completions-###\")}\n\n\\${colors.gray(\\`\n# \\${colors.bold(\"${getAppTitle(context)} Zsh CLI command completion script\")}\n#\n# \\${colors.bold(\"Installation:\")} ${getAppBin(context)} completions zsh --config ~/.zshrc or ${getAppBin(context)} completions zsh --script or ${getAppBin(context)} completions zsh >> ~/.zshrc or ${getAppBin(context)} completions zsh >> ~/.zprofile on OSX. \\`\n)}\n\\${colors.cyan(\"_${getAppBin(context)}_completions()\")}\n{\n local reply\n local si=$IFS\n IFS=$'\\\\n' reply=($(COMP_CWORD=\"$((CURRENT-1))\" COMP_LINE=\"$BUFFER\" COMP_POINT=\"$CURSOR\" ${getAppBin(context)} --get-completions \"\\\\\\${words[@]}\"))\n IFS=$si\n if [[ \\\\\\${#reply} -gt 0 ]]; then\n _describe 'values' reply\n else\n _default\n fi\n}\n\nif [[ \"\\\\\\${zsh_eval_context[-1]}\" == \"loadautofunc\" ]]; then\n _${getAppBin(context)}_completions \"$@\"\nelse\n compdef _${getAppBin(context)}_completions ${getAppBin(context)}\nfi\ncomplete -o bashdefault -o default -F _${getAppBin(context)}_completions ${getAppBin(context)}\n\n\\${colors.gray(\"###-end-${getAppBin(context)}-completions-###\")}\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 ? \"~/.zshrc\" : 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)} Zsh 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.zsh\" : options.script;\n await writeFile(outputPath, stripAnsi(completions));\n\n success(\\`${getAppTitle(context)} Zsh 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":";;;;;;;;;;;;;;;AA4CA,SAAgBgB,wBAAwB;CACtC,MAAMC,UAAUV,eAAyC;AAEzD,QAAAW,gBACGT,gBAAc;EAAA,IACbU,OAAI;AAAA,UAAEJ,UAAUE,QAAQG,WAAW,eAAe,OAAO,aAAa;;EACtEC,SAAS;GACP,WAAW,CAAC,KAAK;GACjB,oBAAoB,CAAC,YAAY,YAAW;GAC7C;EACDC,gBAAgB,EACd,uBAAuB;GACrB;GACA;GACA;GACA;GACA;GAAW,EAEd;EAAA,IAAAC,WAAA;AAAA,UAAA;IAAAL,gBACAR,OAAK,EAACc,SAAO,4CAAA,CAAA;IAAAN,gBACbf,sBAAoB;KAAA,UAAA;KAAQsB,MAAI;KAAA,IAAAF,WAAA;AAAA,aAAA;OAAAL,gBAC9BR,OAAK;QAACc,SAAO;QAAA,IAAAD,WAAA;AAAA,gBAAA,CAAAL,gBACXN,cAAY,EAAAW,UAAE,qEAAmE,CAAA,EAAAL,gBACjFP,mBAAiB;UAAA,IAChBe,OAAI;AAAA,kBAAErB,eAAesB;;UAAM,IAC3BC,eAAY;AAAA,kBAAE,GAAGf,UAAUI,QAAQ,CAAA;;UAAkB,CAAA,CAAA;;QAAA,CAAA;OAAAC,gBAGxDV,iBAAe;QAACiB,MAAI;QAAUI,UAAQ;Q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AEIZ,SAAO,EAAA,CAAA;OAAAY,gBACPhB,aAAW;QAAC+B,WAAWjC,IAAI;QAAgB,IAAAuB,WAAA;AAAA,gBAAA;UAAAL,gBACzCd,gBAAc;WAAA,OAAA;WAEbqB,MAAI;WACJC,MAAI;WACJM,aAAahC,IAAI;WAAuD,CAAA;UAAAkB,gBAEzEZ,SAAO,EAAA,CAAA;UAAAY,gBACPhB,aAAW;WAAC+B,WAAWjC,IAAI;WAAgCuB,UACzDvB,IAAI;WAAwE,CAAA;UAAAkB,gBAE9EZ,SAAO,EAAA,CAAA;UAAAY,gBACPd,gBAAc;WAAA,OAAA;WAEbqB,MAAI;WACJC,MAAI;WACJM,aAAahC,IAAI;WAAK,CAAA;UAAAkB,gBAEvBZ,SAAO,EAAA,CAAA;UAAA4B,WACPlC,IAAI;;;;;;;;;;;;;sBAaOc,YAAYG,QAAQ,CAAA,yLAAyL;UAAA;;QAAA,CAAA;OAAAC,gBAE1NZ,SAAO,EAAA,CAAA;OAAAY,gBACPhB,aAAW;QAAC+B,WAAWjC,IAAI;QAAgB,IAAAuB,WAAA;AAAA,gBACzCvB,IAAI,iDAAiDa,UAAUI,QAAQ,CAAA;;;sBAG5DH,YAAYG,QAAQ,CAAA;;QAA+E,CAAA;OAAAC,gBAEhHZ,SAAO,EAAA,CAAA;OAAAY,gBACPhB,aAAW;QAAC+B,WAAWjC,IAAI;QAAoCuB,UAC7DvB,IAAI;;;QAE6D,CAAA;OAAA;;KAAA,CAAA;IAAA;;EAAA,CAAA"}
1
+ {"version":3,"file":"zsh-command.mjs","names":["code","FunctionDeclaration","IfStatement","InterfaceDeclaration","VarDeclaration","ReflectionKind","Spacing","usePowerlines","InterfaceMember","TypescriptFile","TSDoc","TSDocDefaultValue","TSDocRemarks","getAppBin","getAppTitle","joinPaths","snakeCase","exec","CompletionDirective","ZshCompletionsCommand","context","_$createComponent","path","entryPath","imports","builtinImports","children","heading","name","type","string","defaultValue","optional","async","parameters","initializer","CompletionDirectiveError","CompletionDirectiveNoSpace","CompletionDirectiveNoFileComp","CompletionDirectiveFilterFileExt","CompletionDirectiveFilterDirs","CompletionDirectiveKeepOrder","condition","_$memo"],"sources":["../../src/components/zsh-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\";\nimport { exec } from \"../helpers/complete-command\";\nimport { CompletionDirective } from \"../helpers/completion-directive-constants\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Zsh Completions commands' handler wrapper for the Shell Shock project.\n */\nexport function ZshCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(context.entryPath, \"completions\", \"zsh\", \"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 Zsh completions command.\" />\n <InterfaceDeclaration export name=\"ZshCompletionsOptions\">\n <TSDoc heading=\"The path to write the completion script to.\">\n <TSDocRemarks>{`If no extension is provided, the \\`.zsh\\` extension will be used.`}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue={`${getAppBin(context)}-completions.zsh`}\n />\n </TSDoc>\n <InterfaceMember name=\"script\" optional type=\"string | true\" />\n <Spacing />\n <TSDoc heading=\"The Zsh 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 Zsh configuration file include: \\\\n- \\`~/.zshrc\\` \\\\n- \\`~/.zprofile\\``}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue=\"~/.zshrc\"\n />\n </TSDoc>\n <InterfaceMember name=\"config\" optional type=\"string | true\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions zsh\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[{ name: \"options\", type: \"ZshCompletionsOptions\" }]}>\n <VarDeclaration\n const\n name=\"completions\"\n type=\"string\"\n initializer={code`#compdef ${getAppBin(context)}\ncompdef _${snakeCase(getAppBin(context))} ${getAppBin(context)}\n\n# zsh completion for ${getAppTitle(context)} -*- shell-script -*-\n\n__${snakeCase(getAppBin(context))}_debug() {\n local file=\"$BASH_COMP_DEBUG_FILE\"\n if [[ -n \\${file} ]]; then\n echo \"$*\" >> \"\\${file}\"\n fi\n}\n\n_${getAppBin(context)}() {\n local shellCompDirectiveError=${\n CompletionDirective.CompletionDirectiveError\n }\n local shellCompDirectiveNoSpace=${\n CompletionDirective.CompletionDirectiveNoSpace\n }\n local shellCompDirectiveNoFileComp=${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\n local shellCompDirectiveFilterFileExt=${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\n local shellCompDirectiveFilterDirs=${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\n local shellCompDirectiveKeepOrder=${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n\n local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder\n local -a completions\n\n __${snakeCase(getAppBin(context))}_debug \"\\\\n========= starting completion logic ==========\"\n __${snakeCase(getAppBin(context))}_debug \"CURRENT: \\${CURRENT}, words[*]: \\${words[*]}\"\n\n # The user could have moved the cursor backwards on the command-line.\n # We need to trigger completion from the $CURRENT location, so we need\n # to truncate the command-line ($words) up to the $CURRENT location.\n # (We cannot use $CURSOR as its value does not work when a command is an alias.)\n words=( \"\\${=words[1,CURRENT]}\" )\n __${snakeCase(getAppBin(context))}_debug \"Truncated words[*]: \\${words[*]},\"\n\n lastParam=\\${words[-1]}\n lastChar=\\${lastParam[-1]}\n __${snakeCase(getAppBin(context))}_debug \"lastParam: \\${lastParam}, lastChar: \\${lastChar}\"\n # For zsh, when completing a flag with an = (e.g., ${getAppBin(\n context\n )} -n=<TAB>)\n # completions must be prefixed with the flag\n setopt local_options BASH_REMATCH\n if [[ \"\\${lastParam}\" =~ '-.*=' ]]; then\n # We are dealing with a flag with an =\n flagPrefix=\"-P \\${BASH_REMATCH}\"\n fi\n\n # Prepare the command to obtain completions, ensuring arguments are quoted for eval\n local -a args_to_quote=(\"\\${(@)words[2,-1]}\")\n if [ \"\\${lastChar}\" = \"\" ]; then\n # If the last parameter is complete (there is a space following it)\n # We add an extra empty parameter so we can indicate this to the go completion code.\n __${snakeCase(getAppBin(context))}_debug \"Adding extra empty parameter\"\n args_to_quote+=(\"\")\n fi\n\n # Use Zsh's (q) flag to quote each argument safely for eval\n local quoted_args=(\"\\${(@q)args_to_quote}\")\n\n # Join the main command and the quoted arguments into a single string for eval\n requestComp=\"${exec} complete -- \\${quoted_args[*]}\"\n\n __${snakeCase(getAppBin(context))}_debug \"About to call: eval \\${requestComp}\"\n\n # Use eval to handle any environment variables and such\n out=$(eval \\${requestComp} 2>/dev/null)\n __${snakeCase(getAppBin(context))}_debug \"completion output: \\${out}\"\n\n # Extract the directive integer following a : from the last line\n local lastLine\n while IFS='\\n' read -r line; do\n lastLine=\\${line}\n done < <(printf \"%s\\n\" \"\\${out[@]}\")\n __${snakeCase(getAppBin(context))}_debug \"last line: \\${lastLine}\"\n\n if [ \"\\${lastLine[1]}\" = : ]; then\n directive=\\${lastLine[2,-1]}\n # Remove the directive including the : and the newline\n local suffix\n (( suffix=\\${#lastLine}+2))\n out=\\${out[1,-$suffix]}\n else\n # There is no directive specified. Leave $out as is.\n __${snakeCase(getAppBin(context))}_debug \"No directive found. Setting to default\"\n directive=0\n fi\n\n __${snakeCase(getAppBin(context))}_debug \"directive: \\${directive}\"\n __${snakeCase(getAppBin(context))}_debug \"completions: \\${out}\"\n __${snakeCase(getAppBin(context))}_debug \"flagPrefix: \\${flagPrefix}\"\n\n if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then\n __${snakeCase(getAppBin(context))}_debug \"Completion received error. Ignoring completions.\"\n return\n fi\n\n local activeHelpMarker=\"%\"\n local endIndex=\\${#activeHelpMarker}\n local startIndex=$((\\${#activeHelpMarker}+1))\n local hasActiveHelp=0\n while IFS='\\n' read -r comp; do\n # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)\n if [ \"\\${comp[1,$endIndex]}\" = \"$activeHelpMarker\" ];then\n __${snakeCase(getAppBin(context))}_debug \"ActiveHelp found: $comp\"\n comp=\"\\${comp[$startIndex,-1]}\"\n if [ -n \"$comp\" ]; then\n compadd -x \"\\${comp}\"\n __${snakeCase(getAppBin(context))}_debug \"ActiveHelp will need delimiter\"\n hasActiveHelp=1\n fi\n continue\n fi\n\n if [ -n \"$comp\" ]; then\n # If requested, completions are returned with a description.\n # The description is preceded by a TAB character.\n # For zsh's _describe, we need to use a : instead of a TAB.\n # We first need to escape any : as part of the completion itself.\n comp=\\${comp//:/\\\\:}\n\n local tab=\"$(printf '\\\\t')\"\n comp=\\${comp//$tab/:}\n\n __${snakeCase(getAppBin(context))}_debug \"Adding completion: \\${comp}\"\n completions+=\\${comp}\n lastComp=$comp\n fi\n done < <(printf \"%s\\n\" \"\\${out[@]}\")\n\n # Add a delimiter after the activeHelp statements, but only if:\n # - there are completions following the activeHelp statements, or\n # - file completion will be performed (so there will be choices after the activeHelp)\n if [ $hasActiveHelp -eq 1 ]; then\n if [ \\${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then\n __${snakeCase(getAppBin(context))}_debug \"Adding activeHelp delimiter\"\n compadd -x \"--\"\n hasActiveHelp=0\n fi\n fi\n\n if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then\n __${snakeCase(getAppBin(context))}_debug \"Activating nospace.\"\n noSpace=\"-S ''\"\n fi\n\n if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then\n __${snakeCase(getAppBin(context))}_debug \"Activating keep order.\"\n keepOrder=\"-V\"\n fi\n\n if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then\n # File extension filtering\n local filteringCmd\n filteringCmd='_files'\n for filter in \\${completions[@]}; do\n if [ \\${filter[1]} != '*' ]; then\n # zsh requires a glob pattern to do file filtering\n filter=\"\\\\*.$filter\"\n fi\n filteringCmd+=\" -g $filter\"\n done\n filteringCmd+=\" \\${flagPrefix}\"\n\n __${snakeCase(getAppBin(context))}_debug \"File filtering command: $filteringCmd\"\n _arguments '*:filename:'\"$filteringCmd\"\n elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then\n # File completion for directories only\n local subdir\n subdir=\"\\${completions[1]}\"\n if [ -n \"$subdir\" ]; then\n __${snakeCase(getAppBin(context))}_debug \"Listing directories in $subdir\"\n pushd \"\\${subdir}\" >/dev/null 2>&1\n else\n __${snakeCase(getAppBin(context))}_debug \"Listing directories in .\"\n fi\n\n local result\n _arguments '*:dirname:_files -/'\" \\${flagPrefix}\"\n result=$?\n if [ -n \"$subdir\" ]; then\n popd >/dev/null 2>&1\n fi\n return $result\n else\n __${snakeCase(getAppBin(context))}_debug \"Calling _describe\"\n if eval _describe $keepOrder \"completions\" completions -Q \\${flagPrefix} \\${noSpace}; then\n __${snakeCase(getAppBin(context))}_debug \"_describe found some completions\"\n\n # Return the success of having called _describe\n return 0\n else\n __${snakeCase(getAppBin(context))}_debug \"_describe did not find completions.\"\n __${snakeCase(getAppBin(context))}_debug \"Checking if we should do file completion.\"\n if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then\n __${snakeCase(getAppBin(context))}_debug \"deactivating file completion\"\n\n # Return 0 to indicate completion is finished and prevent zsh from\n # trying other completion algorithms (which could cause hanging).\n # We use NoFileComp directive to explicitly disable file completion.\n return 0\n else\n # Perform file completion\n __${snakeCase(getAppBin(context))}_debug \"Activating file completion\"\n\n # We must return the result of this command, so it must be the\n # last command, or else we must store its result to return it.\n _arguments '*:filename:_files'\" \\${flagPrefix}\"\n fi\n fi\n fi\n}\n\n# don't run the completion function when being sourced or eval-ed\nif [ \"\\${funcstack[1]}\" = \"_${snakeCase(getAppBin(context))}\" ]; then\n _${snakeCase(getAppBin(context))}\nfi\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 ? \"~/.zshrc\" : 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)} Zsh 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.zsh\" : options.script;\n await writeFile(outputPath, stripAnsi(completions));\n\n success(\\`${getAppTitle(context)} Zsh 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":";;;;;;;;;;;;;;;;;;AA+CA,SAAgBmB,wBAAwB;CACtC,MAAMC,UAAUb,eAAyC;AAEzD,QAAAc,gBACGZ,gBAAc;EAAA,IACba,OAAI;AAAA,UAAEP,UAAUK,QAAQG,WAAW,eAAe,OAAO,aAAa;;EACtEC,SAAS;GACP,WAAW,CAAC,KAAK;GACjB,oBAAoB,CAAC,YAAY,YAAW;GAC7C;EACDC,gBAAgB,EACd,uBAAuB;GACrB;GACA;GACA;GACA;GACA;GAAW,EAEd;EAAA,IAAAC,WAAA;AAAA,UAAA;IAAAL,gBACAX,OAAK,EAACiB,SAAO,4CAAA,CAAA;IAAAN,gBACblB,sBAAoB;KAAA,UAAA;KAAQyB,MAAI;KAAA,IAAAF,WAAA;AAAA,aAAA;OAAAL,gBAC9BX,OAAK;QAACiB,SAAO;QAAA,IAAAD,WAAA;AAAA,gBAAA,CAAAL,gBACXT,cAAY,EAAAc,UAAE,qEAAmE,C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,gBAEhHf,SAAO,EAAA,CAAA;OAAAe,gBACPnB,aAAW;QAACwC,WAAW1C,IAAI;QAAoC0B,UAC7D1B,IAAI;;;QAE6D,CAAA;OAAA;;KAAA,CAAA;IAAA;;EAAA,CAAA"}
@@ -0,0 +1,14 @@
1
+
2
+ //#region src/helpers/complete-command.ts
3
+ function quoteIfNeeded(path) {
4
+ return path.includes(" ") ? `'${path}'` : path;
5
+ }
6
+ const execPath = process.execPath;
7
+ const processArgs = process.argv.slice(1);
8
+ const quotedExecPath = quoteIfNeeded(execPath);
9
+ const quotedProcessArgs = processArgs.map(quoteIfNeeded);
10
+ const quotedProcessExecArgs = process.execArgv.map(quoteIfNeeded);
11
+ const exec = `${quotedExecPath} ${quotedProcessExecArgs.join(" ")} ${quotedProcessArgs[0]}`;
12
+
13
+ //#endregion
14
+ exports.exec = exec;
@@ -0,0 +1,5 @@
1
+ //#region src/helpers/complete-command.d.ts
2
+ declare const exec: string;
3
+ //#endregion
4
+ export { exec };
5
+ //# sourceMappingURL=complete-command.d.cts.map