@shell-shock/plugin-completions 0.1.14 → 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
@@ -0,0 +1,419 @@
1
+ import { exec } from "../helpers/complete-command.mjs";
2
+ import { CompletionDirective } from "../helpers/completion-directive-constants.mjs";
3
+ import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
4
+ import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
5
+ import { joinPaths } from "@stryke/path";
6
+ import { code } from "@alloy-js/core";
7
+ import { FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
8
+ import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
9
+ import { Spacing } from "@powerlines/plugin-alloy/core";
10
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
11
+ import { InterfaceMember, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
12
+ import { TSDoc, TSDocDefaultValue, TSDocRemarks } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
13
+ import { snakeCase } from "@stryke/string-format/snake-case";
14
+ import { camelCase } from "@stryke/string-format/camel-case";
15
+
16
+ //#region src/components/powershell-command.tsx
17
+ /**
18
+ * The PowerShell Completions commands' handler wrapper for the Shell Shock project.
19
+ */
20
+ function PowerShellCompletionsCommand() {
21
+ const context = usePowerlines();
22
+ return createComponent(TypescriptFile, {
23
+ get path() {
24
+ return joinPaths(context.entryPath, "completions", "powershell", "command.ts");
25
+ },
26
+ imports: {
27
+ "node:os": ["os"],
28
+ "node:fs/promises": ["readFile", "writeFile"]
29
+ },
30
+ builtinImports: { "shell-shock:console": [
31
+ "colors",
32
+ "writeLine",
33
+ "success",
34
+ "warn",
35
+ "stripAnsi"
36
+ ] },
37
+ get children() {
38
+ return [
39
+ createComponent(TSDoc, { heading: "Options for the PowerShell completions command." }),
40
+ createComponent(InterfaceDeclaration, {
41
+ "export": true,
42
+ name: "PowerShellCompletionsOptions",
43
+ get children() {
44
+ return [
45
+ createComponent(TSDoc, {
46
+ heading: "The path to write the completion script to.",
47
+ get children() {
48
+ return [createComponent(TSDocRemarks, { children: `If no extension is provided, the \`.ps1\` extension will be used.` }), createComponent(TSDocDefaultValue, {
49
+ get type() {
50
+ return ReflectionKind.string;
51
+ },
52
+ get defaultValue() {
53
+ return `${getAppBin(context)}-completions.ps1`;
54
+ }
55
+ })];
56
+ }
57
+ }),
58
+ createComponent(InterfaceMember, {
59
+ name: "script",
60
+ optional: true,
61
+ type: "string | true"
62
+ }),
63
+ createComponent(Spacing, {}),
64
+ createComponent(TSDoc, {
65
+ heading: "The PowerShell configuration file to append the completion script to.",
66
+ get children() {
67
+ return [createComponent(TSDocRemarks, { children: `The generated completion script will be appended to the specified configuration file. Possible values for the PowerShell configuration file include: \\n- \`~/.config/powershell/Microsoft.PowerShell_profile.ps1\`` }), createComponent(TSDocDefaultValue, {
68
+ get type() {
69
+ return ReflectionKind.string;
70
+ },
71
+ defaultValue: "~/.config/powershell/Microsoft.PowerShell_profile.ps1"
72
+ })];
73
+ }
74
+ }),
75
+ createComponent(InterfaceMember, {
76
+ name: "config",
77
+ optional: true,
78
+ type: "string | true"
79
+ })
80
+ ];
81
+ }
82
+ }),
83
+ createComponent(Spacing, {}),
84
+ createComponent(TSDoc, { heading: "Handler logic for the \\`completions powershell\\` command." }),
85
+ createComponent(FunctionDeclaration, {
86
+ "export": true,
87
+ "default": true,
88
+ async: true,
89
+ name: "handler",
90
+ parameters: [{
91
+ name: "options",
92
+ type: "PowerShellCompletionsOptions"
93
+ }],
94
+ get children() {
95
+ return [
96
+ createComponent(VarDeclaration, {
97
+ "const": true,
98
+ name: "completions",
99
+ type: "string",
100
+ get initializer() {
101
+ return code`# powershell completion for ${getAppTitle(context)} -*- shell-script -*-
102
+
103
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
104
+ function __${snakeCase(getAppBin(context))}_debug {
105
+ if ($env:BASH_COMP_DEBUG_FILE) {
106
+ "$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
107
+ }
108
+ }
109
+
110
+ filter __${camelCase(getAppBin(context))}_escapeStringWithSpecialChars {
111
+ $_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\`$&'
112
+ }
113
+
114
+ [scriptblock]$__${camelCase(getAppBin(context))}CompleterBlock = {
115
+ param(
116
+ $WordToComplete,
117
+ $CommandAst,
118
+ $CursorPosition
119
+ )
120
+
121
+ # Get the current command line and convert into a string
122
+ $Command = $CommandAst.CommandElements
123
+ $Command = "$Command"
124
+
125
+ __${camelCase(getAppBin(context))}_debug ""
126
+ __${camelCase(getAppBin(context))}_debug "========= starting completion logic =========="
127
+ __${camelCase(getAppBin(context))}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
128
+
129
+ # The user could have moved the cursor backwards on the command-line.
130
+ # We need to trigger completion from the $CursorPosition location, so we need
131
+ # to truncate the command-line ($Command) up to the $CursorPosition location.
132
+ # Make sure the $Command is longer then the $CursorPosition before we truncate.
133
+ # This happens because the $Command does not include the last space.
134
+ if ($Command.Length -gt $CursorPosition) {
135
+ $Command = $Command.Substring(0, $CursorPosition)
136
+ }
137
+ __${camelCase(getAppBin(context))}_debug "Truncated command: $Command"
138
+
139
+ $ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}
140
+ $ShellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}
141
+ $ShellCompDirectiveNoFileComp=${CompletionDirective.CompletionDirectiveNoFileComp}
142
+ $ShellCompDirectiveFilterFileExt=${CompletionDirective.CompletionDirectiveFilterFileExt}
143
+ $ShellCompDirectiveFilterDirs=${CompletionDirective.CompletionDirectiveFilterDirs}
144
+ $ShellCompDirectiveKeepOrder=${CompletionDirective.CompletionDirectiveKeepOrder}
145
+
146
+ # Prepare the command to request completions for the program.
147
+ # Split the command at the first space to separate the program and arguments.
148
+ $Program, $Arguments = $Command.Split(" ", 2)
149
+
150
+ $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
151
+ __${camelCase(getAppBin(context))}_debug "QuotedArgs: $QuotedArgs"
152
+
153
+ $RequestComp = "& ${exec} complete '--' $QuotedArgs"
154
+ __${camelCase(getAppBin(context))}_debug "RequestComp: $RequestComp"
155
+
156
+ # we cannot use $WordToComplete because it
157
+ # has the wrong values if the cursor was moved
158
+ # so use the last argument
159
+ if ($WordToComplete -ne "" ) {
160
+ $WordToComplete = $Arguments.Split(" ")[-1]
161
+ }
162
+ __${camelCase(getAppBin(context))}_debug "New WordToComplete: $WordToComplete"
163
+
164
+
165
+ # Check for flag with equal sign
166
+ $IsEqualFlag = ($WordToComplete -Like "--*=*" )
167
+ if ( $IsEqualFlag ) {
168
+ __${camelCase(getAppBin(context))}_debug "Completing equal sign flag"
169
+ # Remove the flag part
170
+ $Flag, $WordToComplete = $WordToComplete.Split("=", 2)
171
+ }
172
+
173
+ if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
174
+ # If the last parameter is complete (there is a space following it)
175
+ # We add an extra empty parameter so we can indicate this to the go method.
176
+ __${camelCase(getAppBin(context))}_debug "Adding extra empty parameter"
177
+ # PowerShell 7.2+ changed the way how the arguments are passed to executables,
178
+ # so for pre-7.2 or when Legacy argument passing is enabled we need to use
179
+ if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
180
+ ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or
181
+ (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and
182
+ $PSNativeCommandArgumentPassing -eq 'Legacy')) {
183
+ $RequestComp="$RequestComp" + ' \`"\`"'
184
+ } else {
185
+ $RequestComp = "$RequestComp" + ' ""'
186
+ }
187
+ }
188
+
189
+ __${camelCase(getAppBin(context))}_debug "Calling $RequestComp"
190
+ # First disable ActiveHelp which is not supported for Powershell
191
+ $env:ActiveHelp = 0
192
+
193
+ # call the command store the output in $out and redirect stderr and stdout to null
194
+ # $Out is an array contains each line per element
195
+ Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
196
+
197
+ # get directive from last line
198
+ [int]$Directive = $Out[-1].TrimStart(':')
199
+ if ($Directive -eq "") {
200
+ # There is no directive specified
201
+ $Directive = 0
202
+ }
203
+ __${camelCase(getAppBin(context))}_debug "The completion directive is: $Directive"
204
+
205
+ # remove directive (last element) from out
206
+ $Out = $Out | Where-Object { $_ -ne $Out[-1] }
207
+ __${camelCase(getAppBin(context))}_debug "The completions are: $Out"
208
+ if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
209
+ # Error code. No completion.
210
+ __${camelCase(getAppBin(context))}_debug "Received error from custom completion go code"
211
+ return
212
+ }
213
+
214
+ $Longest = 0
215
+ [Array]$Values = $Out | ForEach-Object {
216
+ # Split the output in name and description
217
+ $Name, $Description = $_.Split("\`t", 2)
218
+ __${camelCase(getAppBin(context))}_debug "Name: $Name Description: $Description"
219
+
220
+ # Look for the longest completion so that we can format things nicely
221
+ if ($Longest -lt $Name.Length) {
222
+ $Longest = $Name.Length
223
+ }
224
+
225
+ # Set the description to a one space string if there is none set.
226
+ # This is needed because the CompletionResult does not accept an empty string as argument
227
+ if (-Not $Description) {
228
+ $Description = " "
229
+ }
230
+ @{ Name = "$Name"; Description = "$Description" }
231
+ }
232
+
233
+
234
+ $Space = " "
235
+ if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
236
+ # remove the space here
237
+ __${camelCase(getAppBin(context))}_debug "ShellCompDirectiveNoSpace is called"
238
+ $Space = ""
239
+ }
240
+
241
+ if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
242
+ (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
243
+ __${camelCase(getAppBin(context))}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
244
+
245
+ # return here to prevent the completion of the extensions
246
+ return
247
+ }
248
+
249
+ $Values = $Values | Where-Object {
250
+ # filter the result
251
+ $_.Name -like "$WordToComplete*"
252
+
253
+ # Join the flag back if we have an equal sign flag
254
+ if ( $IsEqualFlag ) {
255
+ __${camelCase(getAppBin(context))}_debug "Join the equal sign flag back to the completion value"
256
+ $_.Name = $Flag + "=" + $_.Name
257
+ }
258
+ }
259
+
260
+ # we sort the values in ascending order by name if keep order isn't passed
261
+ if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {
262
+ $Values = $Values | Sort-Object -Property Name
263
+ }
264
+
265
+ if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
266
+ __${camelCase(getAppBin(context))}_debug "ShellCompDirectiveNoFileComp is called"
267
+
268
+ if ($Values.Length -eq 0) {
269
+ # Just print an empty string here so the
270
+ # shell does not start to complete paths.
271
+ # We cannot use CompletionResult here because
272
+ # it does not accept an empty string as argument.
273
+ ""
274
+ return
275
+ }
276
+ }
277
+
278
+ # Get the current mode
279
+ $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
280
+ __${camelCase(getAppBin(context))}_debug "Mode: $Mode"
281
+
282
+ $Values | ForEach-Object {
283
+
284
+ # store temporary because switch will overwrite $_
285
+ $comp = $_
286
+
287
+ # PowerShell supports three different completion modes
288
+ # - TabCompleteNext (default windows style - on each key press the next option is displayed)
289
+ # - Complete (works like bash)
290
+ # - MenuComplete (works like zsh)
291
+ # You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
292
+
293
+ # CompletionResult Arguments:
294
+ # 1) CompletionText text to be used as the auto completion result
295
+ # 2) ListItemText text to be displayed in the suggestion list
296
+ # 3) ResultType type of completion result
297
+ # 4) ToolTip text for the tooltip with details about the object
298
+
299
+ switch ($Mode) {
300
+
301
+ # bash like
302
+ "Complete" {
303
+
304
+ if ($Values.Length -eq 1) {
305
+ __${camelCase(getAppBin(context))}_debug "Only one completion left"
306
+
307
+ # insert space after value
308
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
309
+
310
+ } else {
311
+ # Add the proper number of spaces to align the descriptions
312
+ while($comp.Name.Length -lt $Longest) {
313
+ $comp.Name = $comp.Name + " "
314
+ }
315
+
316
+ # Check for empty description and only add parentheses if needed
317
+ if ($($comp.Description) -eq " " ) {
318
+ $Description = ""
319
+ } else {
320
+ $Description = " ($($comp.Description))"
321
+ }
322
+
323
+ [System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
324
+ }
325
+ }
326
+
327
+ # zsh like
328
+ "MenuComplete" {
329
+ # insert space after value
330
+ # MenuComplete will automatically show the ToolTip of
331
+ # the highlighted value at the bottom of the suggestions.
332
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
333
+ }
334
+
335
+ # TabCompleteNext and in case we get something unknown
336
+ Default {
337
+ # Like MenuComplete but we don't want to add a space here because
338
+ # the user need to press space anyway to get the completion.
339
+ # Description will not be shown because that's not possible with TabCompleteNext
340
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
341
+ }
342
+ }
343
+
344
+ }
345
+ }
346
+
347
+ Register-ArgumentCompleter -CommandName '${getAppBin(context)}' -ScriptBlock $__${camelCase(getAppBin(context))}CompleterBlock
348
+ \`); `;
349
+ }
350
+ }),
351
+ createComponent(Spacing, {}),
352
+ createComponent(IfStatement, {
353
+ condition: code`options.config`,
354
+ get children() {
355
+ return [
356
+ createComponent(VarDeclaration, {
357
+ "let": true,
358
+ name: "configFilePath",
359
+ type: "string",
360
+ initializer: code`options.config === true ? "~/.config/powershell/Microsoft.PowerShell_profile.ps1" : options.config`
361
+ }),
362
+ createComponent(Spacing, {}),
363
+ createComponent(IfStatement, {
364
+ condition: code`configFilePath.startsWith("~")`,
365
+ children: code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
366
+ }),
367
+ createComponent(Spacing, {}),
368
+ createComponent(VarDeclaration, {
369
+ "let": true,
370
+ name: "configFileContent",
371
+ type: "string",
372
+ initializer: code`"";`
373
+ }),
374
+ createComponent(Spacing, {}),
375
+ memo(() => code`try {
376
+ configFileContent = await readFile(configFilePath, "utf8");
377
+ } catch (error) {
378
+ if (error.code === "ENOENT") {
379
+ // If the file doesn't exist, we can create it later when writing the completion script.
380
+ warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
381
+ } else {
382
+ return { error };
383
+ }
384
+ }
385
+
386
+ await writeFile(configFilePath, \`\${configFileContent}\\n\\n\${stripAnsi(completions)}\`);
387
+
388
+ success(\`${getAppTitle(context)} PowerShell completion script has been generated and appended to \${colors.bold(configFilePath)}. Please restart your terminal or run \`source \${configFilePath}\` to apply the changes.\`); `)
389
+ ];
390
+ }
391
+ }),
392
+ createComponent(Spacing, {}),
393
+ createComponent(IfStatement, {
394
+ condition: code`options.script`,
395
+ get children() {
396
+ return code`const outputPath = options.script === true ? "${getAppBin(context)}-completions.powershell" : options.script;
397
+ await writeFile(outputPath, stripAnsi(completions));
398
+
399
+ success(\`${getAppTitle(context)} PowerShell completion script has been generated at \${colors.bold(outputPath)}.\`);`;
400
+ }
401
+ }),
402
+ createComponent(Spacing, {}),
403
+ createComponent(IfStatement, {
404
+ condition: code`!options.config && !options.script`,
405
+ children: code`writeLine(" ------------------------------------------------- ");
406
+ writeLine(completions);
407
+ writeLine(" ------------------------------------------------- ");`
408
+ })
409
+ ];
410
+ }
411
+ })
412
+ ];
413
+ }
414
+ });
415
+ }
416
+
417
+ //#endregion
418
+ export { PowerShellCompletionsCommand };
419
+ //# sourceMappingURL=powershell-command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-command.mjs","names":["code","FunctionDeclaration","IfStatement","InterfaceDeclaration","VarDeclaration","ReflectionKind","Spacing","usePowerlines","InterfaceMember","TypescriptFile","TSDoc","TSDocDefaultValue","TSDocRemarks","getAppBin","getAppTitle","joinPaths","camelCase","snakeCase","exec","CompletionDirective","PowerShellCompletionsCommand","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/powershell-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 { camelCase } from \"@stryke/string-format/camel-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { exec } from \"../helpers/complete-command\";\nimport { CompletionDirective } from \"../helpers/completion-directive-constants\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The PowerShell Completions commands' handler wrapper for the Shell Shock project.\n */\nexport function PowerShellCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"powershell\",\n \"command.ts\"\n )}\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 PowerShell completions command.\" />\n <InterfaceDeclaration export name=\"PowerShellCompletionsOptions\">\n <TSDoc heading=\"The path to write the completion script to.\">\n <TSDocRemarks>{`If no extension is provided, the \\`.ps1\\` extension will be used.`}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue={`${getAppBin(context)}-completions.ps1`}\n />\n </TSDoc>\n <InterfaceMember name=\"script\" optional type=\"string | true\" />\n <Spacing />\n <TSDoc heading=\"The PowerShell 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 PowerShell configuration file include: \\\\n- \\`~/.config/powershell/Microsoft.PowerShell_profile.ps1\\``}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue=\"~/.config/powershell/Microsoft.PowerShell_profile.ps1\"\n />\n </TSDoc>\n <InterfaceMember name=\"config\" optional type=\"string | true\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions powershell\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n { name: \"options\", type: \"PowerShellCompletionsOptions\" }\n ]}>\n <VarDeclaration\n const\n name=\"completions\"\n type=\"string\"\n initializer={code`# powershell completion for ${getAppTitle(context)} -*- shell-script -*-\n\n [Console]::OutputEncoding = [System.Text.Encoding]::UTF8\n function __${snakeCase(getAppBin(context))}_debug {\n if ($env:BASH_COMP_DEBUG_FILE) {\n \"$args\" | Out-File -Append -FilePath \"$env:BASH_COMP_DEBUG_FILE\"\n }\n }\n\n filter __${camelCase(getAppBin(context))}_escapeStringWithSpecialChars {\n $_ -replace '\\\\s|#|@|\\\\$|;|,|''|\\\\{|\\\\}|\\\\(|\\\\)|\"|\\\\||<|>|&','\\`$&'\n }\n\n[scriptblock]$__${camelCase(getAppBin(context))}CompleterBlock = {\n param(\n $WordToComplete,\n $CommandAst,\n $CursorPosition\n )\n\n # Get the current command line and convert into a string\n $Command = $CommandAst.CommandElements\n $Command = \"$Command\"\n\n __${camelCase(getAppBin(context))}_debug \"\"\n __${camelCase(getAppBin(context))}_debug \"========= starting completion logic ==========\"\n __${camelCase(getAppBin(context))}_debug \"WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition\"\n\n # The user could have moved the cursor backwards on the command-line.\n # We need to trigger completion from the $CursorPosition location, so we need\n # to truncate the command-line ($Command) up to the $CursorPosition location.\n # Make sure the $Command is longer then the $CursorPosition before we truncate.\n # This happens because the $Command does not include the last space.\n if ($Command.Length -gt $CursorPosition) {\n $Command = $Command.Substring(0, $CursorPosition)\n }\n __${camelCase(getAppBin(context))}_debug \"Truncated command: $Command\"\n\n $ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}\n $ShellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}\n $ShellCompDirectiveNoFileComp=${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\n $ShellCompDirectiveFilterFileExt=${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\n $ShellCompDirectiveFilterDirs=${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\n $ShellCompDirectiveKeepOrder=${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n\n # Prepare the command to request completions for the program.\n # Split the command at the first space to separate the program and arguments.\n $Program, $Arguments = $Command.Split(\" \", 2)\n\n $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { \"'\" + ($_ -replace \"'\", \"''\") + \"'\" }) -join ' '\n __${camelCase(getAppBin(context))}_debug \"QuotedArgs: $QuotedArgs\"\n\n $RequestComp = \"& ${exec} complete '--' $QuotedArgs\"\n __${camelCase(getAppBin(context))}_debug \"RequestComp: $RequestComp\"\n\n # we cannot use $WordToComplete because it\n # has the wrong values if the cursor was moved\n # so use the last argument\n if ($WordToComplete -ne \"\" ) {\n $WordToComplete = $Arguments.Split(\" \")[-1]\n }\n __${camelCase(getAppBin(context))}_debug \"New WordToComplete: $WordToComplete\"\n\n\n # Check for flag with equal sign\n $IsEqualFlag = ($WordToComplete -Like \"--*=*\" )\n if ( $IsEqualFlag ) {\n __${camelCase(getAppBin(context))}_debug \"Completing equal sign flag\"\n # Remove the flag part\n $Flag, $WordToComplete = $WordToComplete.Split(\"=\", 2)\n }\n\n if ( $WordToComplete -eq \"\" -And ( -Not $IsEqualFlag )) {\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 method.\n __${camelCase(getAppBin(context))}_debug \"Adding extra empty parameter\"\n # PowerShell 7.2+ changed the way how the arguments are passed to executables,\n # so for pre-7.2 or when Legacy argument passing is enabled we need to use\n if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or\n ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled(\"PSNativeCommandArgumentPassing\")) -or\n (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled(\"PSNativeCommandArgumentPassing\")) -and\n $PSNativeCommandArgumentPassing -eq 'Legacy')) {\n $RequestComp=\"$RequestComp\" + ' \\`\"\\`\"'\n } else {\n $RequestComp = \"$RequestComp\" + ' \"\"'\n }\n }\n\n __${camelCase(getAppBin(context))}_debug \"Calling $RequestComp\"\n # First disable ActiveHelp which is not supported for Powershell\n $env:ActiveHelp = 0\n\n # call the command store the output in $out and redirect stderr and stdout to null\n # $Out is an array contains each line per element\n Invoke-Expression -OutVariable out \"$RequestComp\" 2>&1 | Out-Null\n\n # get directive from last line\n [int]$Directive = $Out[-1].TrimStart(':')\n if ($Directive -eq \"\") {\n # There is no directive specified\n $Directive = 0\n }\n __${camelCase(getAppBin(context))}_debug \"The completion directive is: $Directive\"\n\n # remove directive (last element) from out\n $Out = $Out | Where-Object { $_ -ne $Out[-1] }\n __${camelCase(getAppBin(context))}_debug \"The completions are: $Out\"\n if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {\n # Error code. No completion.\n __${camelCase(getAppBin(context))}_debug \"Received error from custom completion go code\"\n return\n }\n\n $Longest = 0\n [Array]$Values = $Out | ForEach-Object {\n # Split the output in name and description\n $Name, $Description = $_.Split(\"\\`t\", 2)\n __${camelCase(getAppBin(context))}_debug \"Name: $Name Description: $Description\"\n\n # Look for the longest completion so that we can format things nicely\n if ($Longest -lt $Name.Length) {\n $Longest = $Name.Length\n }\n\n # Set the description to a one space string if there is none set.\n # This is needed because the CompletionResult does not accept an empty string as argument\n if (-Not $Description) {\n $Description = \" \"\n }\n @{ Name = \"$Name\"; Description = \"$Description\" }\n }\n\n\n $Space = \" \"\n if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {\n # remove the space here\n __${camelCase(getAppBin(context))}_debug \"ShellCompDirectiveNoSpace is called\"\n $Space = \"\"\n }\n\n if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or\n (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {\n __${camelCase(getAppBin(context))}_debug \"ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported\"\n\n # return here to prevent the completion of the extensions\n return\n }\n\n $Values = $Values | Where-Object {\n # filter the result\n $_.Name -like \"$WordToComplete*\"\n\n # Join the flag back if we have an equal sign flag\n if ( $IsEqualFlag ) {\n __${camelCase(getAppBin(context))}_debug \"Join the equal sign flag back to the completion value\"\n $_.Name = $Flag + \"=\" + $_.Name\n }\n }\n\n # we sort the values in ascending order by name if keep order isn't passed\n if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {\n $Values = $Values | Sort-Object -Property Name\n }\n\n if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {\n __${camelCase(getAppBin(context))}_debug \"ShellCompDirectiveNoFileComp is called\"\n\n if ($Values.Length -eq 0) {\n # Just print an empty string here so the\n # shell does not start to complete paths.\n # We cannot use CompletionResult here because\n # it does not accept an empty string as argument.\n \"\"\n return\n }\n }\n\n # Get the current mode\n $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq \"Tab\" }).Function\n __${camelCase(getAppBin(context))}_debug \"Mode: $Mode\"\n\n $Values | ForEach-Object {\n\n # store temporary because switch will overwrite $_\n $comp = $_\n\n # PowerShell supports three different completion modes\n # - TabCompleteNext (default windows style - on each key press the next option is displayed)\n # - Complete (works like bash)\n # - MenuComplete (works like zsh)\n # You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>\n\n # CompletionResult Arguments:\n # 1) CompletionText text to be used as the auto completion result\n # 2) ListItemText text to be displayed in the suggestion list\n # 3) ResultType type of completion result\n # 4) ToolTip text for the tooltip with details about the object\n\n switch ($Mode) {\n\n # bash like\n \"Complete\" {\n\n if ($Values.Length -eq 1) {\n __${camelCase(\n getAppBin(context)\n )}_debug \"Only one completion left\"\n\n # insert space after value\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars) + $Space, \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n\n } else {\n # Add the proper number of spaces to align the descriptions\n while($comp.Name.Length -lt $Longest) {\n $comp.Name = $comp.Name + \" \"\n }\n\n # Check for empty description and only add parentheses if needed\n if ($($comp.Description) -eq \" \" ) {\n $Description = \"\"\n } else {\n $Description = \" ($($comp.Description))\"\n }\n\n [System.Management.Automation.CompletionResult]::new(\"$($comp.Name)$Description\", \"$($comp.Name)$Description\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n\n # zsh like\n \"MenuComplete\" {\n # insert space after value\n # MenuComplete will automatically show the ToolTip of\n # the highlighted value at the bottom of the suggestions.\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars) + $Space, \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n\n # TabCompleteNext and in case we get something unknown\n Default {\n # Like MenuComplete but we don't want to add a space here because\n # the user need to press space anyway to get the completion.\n # Description will not be shown because that's not possible with TabCompleteNext\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars), \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n\n }\n}\n\nRegister-ArgumentCompleter -CommandName '${getAppBin(\n context\n )}' -ScriptBlock $__${camelCase(getAppBin(context))}CompleterBlock\n\\`); `}\n />\n <Spacing />\n <IfStatement condition={code`options.config`}>\n <VarDeclaration\n let\n name=\"configFilePath\"\n type=\"string\"\n initializer={code`options.config === true ? \"~/.config/powershell/Microsoft.PowerShell_profile.ps1\" : 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)} PowerShell 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.powershell\" : options.script;\n await writeFile(outputPath, stripAnsi(completions));\n\n success(\\`${getAppTitle(context)} PowerShell 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>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