@shell-shock/plugin-completions 0.4.16 → 0.4.19

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 (113) hide show
  1. package/dist/components/bash-config-command.cjs +116 -6
  2. package/dist/components/bash-config-command.d.cts +1 -3
  3. package/dist/components/bash-config-command.d.cts.map +1 -1
  4. package/dist/components/bash-config-command.d.mts +1 -3
  5. package/dist/components/bash-config-command.d.mts.map +1 -1
  6. package/dist/components/bash-config-command.mjs +115 -6
  7. package/dist/components/bash-config-command.mjs.map +1 -1
  8. package/dist/components/bash-script-command.cjs +101 -5
  9. package/dist/components/bash-script-command.d.cts +1 -3
  10. package/dist/components/bash-script-command.d.cts.map +1 -1
  11. package/dist/components/bash-script-command.d.mts +1 -3
  12. package/dist/components/bash-script-command.d.mts.map +1 -1
  13. package/dist/components/bash-script-command.mjs +100 -5
  14. package/dist/components/bash-script-command.mjs.map +1 -1
  15. package/dist/components/bash-shared.cjs +77 -13
  16. package/dist/components/bash-shared.d.cts +1 -3
  17. package/dist/components/bash-shared.d.cts.map +1 -1
  18. package/dist/components/bash-shared.d.mts +1 -3
  19. package/dist/components/bash-shared.d.mts.map +1 -1
  20. package/dist/components/bash-shared.mjs +76 -13
  21. package/dist/components/bash-shared.mjs.map +1 -1
  22. package/dist/components/fish-config-command.cjs +116 -6
  23. package/dist/components/fish-config-command.d.cts +1 -3
  24. package/dist/components/fish-config-command.d.cts.map +1 -1
  25. package/dist/components/fish-config-command.d.mts +1 -3
  26. package/dist/components/fish-config-command.d.mts.map +1 -1
  27. package/dist/components/fish-config-command.mjs +115 -6
  28. package/dist/components/fish-config-command.mjs.map +1 -1
  29. package/dist/components/fish-script-command.cjs +100 -4
  30. package/dist/components/fish-script-command.d.cts +1 -3
  31. package/dist/components/fish-script-command.d.cts.map +1 -1
  32. package/dist/components/fish-script-command.d.mts +1 -3
  33. package/dist/components/fish-script-command.d.mts.map +1 -1
  34. package/dist/components/fish-script-command.mjs +99 -4
  35. package/dist/components/fish-script-command.mjs.map +1 -1
  36. package/dist/components/fish-shared.cjs +141 -77
  37. package/dist/components/fish-shared.d.cts +1 -3
  38. package/dist/components/fish-shared.d.cts.map +1 -1
  39. package/dist/components/fish-shared.d.mts +1 -3
  40. package/dist/components/fish-shared.d.mts.map +1 -1
  41. package/dist/components/fish-shared.mjs +140 -77
  42. package/dist/components/fish-shared.mjs.map +1 -1
  43. package/dist/components/index.cjs +26 -1
  44. package/dist/components/index.mjs +14 -1
  45. package/dist/components/powershell-config-command.cjs +112 -6
  46. package/dist/components/powershell-config-command.d.cts +1 -3
  47. package/dist/components/powershell-config-command.d.cts.map +1 -1
  48. package/dist/components/powershell-config-command.d.mts +1 -3
  49. package/dist/components/powershell-config-command.d.mts.map +1 -1
  50. package/dist/components/powershell-config-command.mjs +111 -6
  51. package/dist/components/powershell-config-command.mjs.map +1 -1
  52. package/dist/components/powershell-script-command.cjs +100 -4
  53. package/dist/components/powershell-script-command.d.cts +1 -3
  54. package/dist/components/powershell-script-command.d.cts.map +1 -1
  55. package/dist/components/powershell-script-command.d.mts +1 -3
  56. package/dist/components/powershell-script-command.d.mts.map +1 -1
  57. package/dist/components/powershell-script-command.mjs +99 -4
  58. package/dist/components/powershell-script-command.mjs.map +1 -1
  59. package/dist/components/powershell-shared.cjs +101 -37
  60. package/dist/components/powershell-shared.d.cts +1 -3
  61. package/dist/components/powershell-shared.d.cts.map +1 -1
  62. package/dist/components/powershell-shared.d.mts +1 -3
  63. package/dist/components/powershell-shared.d.mts.map +1 -1
  64. package/dist/components/powershell-shared.mjs +100 -37
  65. package/dist/components/powershell-shared.mjs.map +1 -1
  66. package/dist/components/zsh-config-command.cjs +116 -6
  67. package/dist/components/zsh-config-command.d.cts +1 -3
  68. package/dist/components/zsh-config-command.d.cts.map +1 -1
  69. package/dist/components/zsh-config-command.d.mts +1 -3
  70. package/dist/components/zsh-config-command.d.mts.map +1 -1
  71. package/dist/components/zsh-config-command.mjs +115 -6
  72. package/dist/components/zsh-config-command.mjs.map +1 -1
  73. package/dist/components/zsh-script-command.cjs +104 -6
  74. package/dist/components/zsh-script-command.d.cts +1 -3
  75. package/dist/components/zsh-script-command.d.cts.map +1 -1
  76. package/dist/components/zsh-script-command.d.mts +1 -3
  77. package/dist/components/zsh-script-command.d.mts.map +1 -1
  78. package/dist/components/zsh-script-command.mjs +103 -6
  79. package/dist/components/zsh-script-command.mjs.map +1 -1
  80. package/dist/components/zsh-shared.cjs +106 -42
  81. package/dist/components/zsh-shared.d.cts +1 -3
  82. package/dist/components/zsh-shared.d.cts.map +1 -1
  83. package/dist/components/zsh-shared.d.mts +1 -3
  84. package/dist/components/zsh-shared.d.mts.map +1 -1
  85. package/dist/components/zsh-shared.mjs +105 -42
  86. package/dist/components/zsh-shared.mjs.map +1 -1
  87. package/dist/helpers/complete-command.cjs +10 -1
  88. package/dist/helpers/complete-command.d.mts.map +1 -1
  89. package/dist/helpers/complete-command.mjs +8 -1
  90. package/dist/helpers/complete-command.mjs.map +1 -1
  91. package/dist/helpers/completion-directive-constants.cjs +16 -1
  92. package/dist/helpers/completion-directive-constants.d.mts.map +1 -1
  93. package/dist/helpers/completion-directive-constants.mjs +14 -1
  94. package/dist/helpers/completion-directive-constants.mjs.map +1 -1
  95. package/dist/helpers/index.cjs +6 -1
  96. package/dist/helpers/index.mjs +4 -1
  97. package/dist/index.cjs +290 -1
  98. package/dist/index.d.cts +2 -2
  99. package/dist/index.d.mts +2 -2
  100. package/dist/index.d.mts.map +1 -1
  101. package/dist/index.mjs +288 -1
  102. package/dist/index.mjs.map +1 -1
  103. package/dist/types/index.cjs +4 -1
  104. package/dist/types/index.mjs +3 -1
  105. package/dist/types/plugin.d.cts.map +1 -1
  106. package/dist/types/plugin.d.mts.map +1 -1
  107. package/dist/types/plugin.mjs +1 -1
  108. package/dist/types/shell-type.cjs +12 -1
  109. package/dist/types/shell-type.d.cts.map +1 -1
  110. package/dist/types/shell-type.d.mts.map +1 -1
  111. package/dist/types/shell-type.mjs +10 -1
  112. package/dist/types/shell-type.mjs.map +1 -1
  113. package/package.json +13 -13
@@ -1,17 +1,65 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../helpers/complete-command.cjs`),t=require(`../helpers/completion-directive-constants.cjs`);require(`../helpers/index.cjs`);let n=require(`@alloy-js/core/jsx-runtime`),r=require(`@shell-shock/core/plugin-utils`),i=require(`@alloy-js/core`),a=require(`@alloy-js/typescript`),o=require(`@powerlines/plugin-alloy/core`),s=require(`@powerlines/plugin-alloy/core/contexts/context`),c=require(`@powerlines/plugin-alloy/typescript`),l=require(`@stryke/path`),u=require(`@stryke/string-format/camel-case`);function d(){let d=(0,s.usePowerlines)(),f=(0,i.computed)(()=>(0,r.getAppBin)(d)),p=(0,i.computed)(()=>(0,u.camelCase)(f.value));return(0,n.createComponent)(c.TypescriptFile,{get path(){return(0,l.joinPaths)(d.entryPath,`completions`,`powershell`,`shared.ts`)},builtinImports:{console:[`white`,`green`,`red`,`bold`,`cyan`,`gray`,`magenta`,`magentaBright`,`greenBright`,`redBright`,`cyanBright`,`dim`]},get children(){return[(0,n.createComponent)(o.Spacing,{}),(0,n.createComponent)(a.VarDeclaration,{const:!0,export:!0,name:`SHELL_COMPLETIONS`,get initializer(){return i.code` \`# powershell completion for ${(0,r.getAppTitle)(d)}
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_helpers_complete_command = require('../helpers/complete-command.cjs');
3
+ const require_helpers_completion_directive_constants = require('../helpers/completion-directive-constants.cjs');
4
+ require('../helpers/index.cjs');
5
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
6
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
7
+ let _alloy_js_core = require("@alloy-js/core");
8
+ let _alloy_js_typescript = require("@alloy-js/typescript");
9
+ let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
10
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
11
+ let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
12
+ let _stryke_path = require("@stryke/path");
13
+ let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
14
+
15
+ //#region src/components/powershell-shared.tsx
16
+ /**
17
+ * The PowerShell Completions generation for the Shell Shock project.
18
+ */
19
+ function PowerShellCompletionsShared() {
20
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
21
+ const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
22
+ const name = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_camel_case.camelCase)(bin.value));
23
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
24
+ get path() {
25
+ return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "powershell", "shared.ts");
26
+ },
27
+ builtinImports: { console: [
28
+ "white",
29
+ "green",
30
+ "red",
31
+ "bold",
32
+ "cyan",
33
+ "gray",
34
+ "magenta",
35
+ "magentaBright",
36
+ "greenBright",
37
+ "redBright",
38
+ "cyanBright",
39
+ "dim"
40
+ ] },
41
+ get children() {
42
+ return [
43
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
44
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
45
+ "const": true,
46
+ "export": true,
47
+ name: "SHELL_COMPLETIONS",
48
+ get initializer() {
49
+ return _alloy_js_core.code` \`# powershell completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}
2
50
 
3
51
  [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
4
- function __${p.value}_debug {
52
+ function __${name.value}_debug {
5
53
  if ($env:BASH_COMP_DEBUG_FILE) {
6
54
  "$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
7
55
  }
8
56
  }
9
57
 
10
- filter __${p.value}_escapeStringWithSpecialChars {
58
+ filter __${name.value}_escapeStringWithSpecialChars {
11
59
  $_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\\\`$&'
12
60
  }
13
61
 
14
- [scriptblock]$__${p.value}CompleterBlock = {
62
+ [scriptblock]$__${name.value}CompleterBlock = {
15
63
  param(
16
64
  $WordToComplete,
17
65
  $CommandAst,
@@ -22,9 +70,9 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
22
70
  $Command = $CommandAst.CommandElements
23
71
  $Command = "$Command"
24
72
 
25
- __${p.value}_debug ""
26
- __${p.value}_debug "========= starting completion logic =========="
27
- __${p.value}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
73
+ __${name.value}_debug ""
74
+ __${name.value}_debug "========= starting completion logic =========="
75
+ __${name.value}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
28
76
 
29
77
  # The user could have moved the cursor backwards on the command-line.
30
78
  # We need to trigger completion from the $CursorPosition location, so we need
@@ -34,24 +82,24 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
34
82
  if ($Command.Length -gt $CursorPosition) {
35
83
  $Command = $Command.Substring(0, $CursorPosition)
36
84
  }
37
- __${p.value}_debug "Truncated command: $Command"
85
+ __${name.value}_debug "Truncated command: $Command"
38
86
 
39
- $ShellCompDirectiveError=${t.CompletionDirective.CompletionDirectiveError}
40
- $ShellCompDirectiveNoSpace=${t.CompletionDirective.CompletionDirectiveNoSpace}
41
- $ShellCompDirectiveNoFileComp=${t.CompletionDirective.CompletionDirectiveNoFileComp}
42
- $ShellCompDirectiveFilterFileExt=${t.CompletionDirective.CompletionDirectiveFilterFileExt}
43
- $ShellCompDirectiveFilterDirs=${t.CompletionDirective.CompletionDirectiveFilterDirs}
44
- $ShellCompDirectiveKeepOrder=${t.CompletionDirective.CompletionDirectiveKeepOrder}
87
+ $ShellCompDirectiveError=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
88
+ $ShellCompDirectiveNoSpace=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
89
+ $ShellCompDirectiveNoFileComp=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoFileComp}
90
+ $ShellCompDirectiveFilterFileExt=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterFileExt}
91
+ $ShellCompDirectiveFilterDirs=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterDirs}
92
+ $ShellCompDirectiveKeepOrder=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
45
93
 
46
94
  # Prepare the command to request completions for the program.
47
95
  # Split the command at the first space to separate the program and arguments.
48
96
  $Program, $Arguments = $Command.Split(" ", 2)
49
97
 
50
98
  $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
51
- __${p.value}_debug "QuotedArgs: $QuotedArgs"
99
+ __${name.value}_debug "QuotedArgs: $QuotedArgs"
52
100
 
53
- $RequestComp = "& ${e.EXEC_COMMAND} complete '--' $QuotedArgs"
54
- __${p.value}_debug "RequestComp: $RequestComp"
101
+ $RequestComp = "& ${require_helpers_complete_command.EXEC_COMMAND} complete '--' $QuotedArgs"
102
+ __${name.value}_debug "RequestComp: $RequestComp"
55
103
 
56
104
  # we cannot use $WordToComplete because it
57
105
  # has the wrong values if the cursor was moved
@@ -59,13 +107,13 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
59
107
  if ($WordToComplete -ne "" ) {
60
108
  $WordToComplete = $Arguments.Split(" ")[-1]
61
109
  }
62
- __${p.value}_debug "New WordToComplete: $WordToComplete"
110
+ __${name.value}_debug "New WordToComplete: $WordToComplete"
63
111
 
64
112
 
65
113
  # Check for flag with equal sign
66
114
  $IsEqualFlag = ($WordToComplete -Like "--*=*" )
67
115
  if ( $IsEqualFlag ) {
68
- __${p.value}_debug "Completing equal sign flag"
116
+ __${name.value}_debug "Completing equal sign flag"
69
117
  # Remove the flag part
70
118
  $Flag, $WordToComplete = $WordToComplete.Split("=", 2)
71
119
  }
@@ -73,7 +121,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
73
121
  if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
74
122
  # If the last parameter is complete (there is a space following it)
75
123
  # We add an extra empty parameter so we can indicate this to the go method.
76
- __${p.value}_debug "Adding extra empty parameter"
124
+ __${name.value}_debug "Adding extra empty parameter"
77
125
  # PowerShell 7.2+ changed the way how the arguments are passed to executables,
78
126
  # so for pre-7.2 or when Legacy argument passing is enabled we need to use
79
127
  if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
@@ -86,7 +134,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
86
134
  }
87
135
  }
88
136
 
89
- __${p.value}_debug "Calling $RequestComp"
137
+ __${name.value}_debug "Calling $RequestComp"
90
138
  # First disable ActiveHelp which is not supported for Powershell
91
139
  $env:ActiveHelp = 0
92
140
 
@@ -100,14 +148,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
100
148
  # There is no directive specified
101
149
  $Directive = 0
102
150
  }
103
- __${p.value}_debug "The completion directive is: $Directive"
151
+ __${name.value}_debug "The completion directive is: $Directive"
104
152
 
105
153
  # remove directive (last element) from out
106
154
  $Out = $Out | Where-Object { $_ -ne $Out[-1] }
107
- __${p.value}_debug "The completions are: $Out"
155
+ __${name.value}_debug "The completions are: $Out"
108
156
  if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
109
157
  # Error code. No completion.
110
- __${p.value}_debug "Received error from custom completion go code"
158
+ __${name.value}_debug "Received error from custom completion go code"
111
159
  return
112
160
  }
113
161
 
@@ -115,7 +163,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
115
163
  [Array]$Values = $Out | ForEach-Object {
116
164
  # Split the output in name and description
117
165
  $Name, $Description = $_.Split("\\\`t", 2)
118
- __${p.value}_debug "Name: $Name Description: $Description"
166
+ __${name.value}_debug "Name: $Name Description: $Description"
119
167
 
120
168
  # Look for the longest completion so that we can format things nicely
121
169
  if ($Longest -lt $Name.Length) {
@@ -134,13 +182,13 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
134
182
  $Space = " "
135
183
  if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
136
184
  # remove the space here
137
- __${p.value}_debug "ShellCompDirectiveNoSpace is called"
185
+ __${name.value}_debug "ShellCompDirectiveNoSpace is called"
138
186
  $Space = ""
139
187
  }
140
188
 
141
189
  if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
142
190
  (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
143
- __${p.value}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
191
+ __${name.value}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
144
192
 
145
193
  # return here to prevent the completion of the extensions
146
194
  return
@@ -152,7 +200,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
152
200
 
153
201
  # Join the flag back if we have an equal sign flag
154
202
  if ( $IsEqualFlag ) {
155
- __${p.value}_debug "Join the equal sign flag back to the completion value"
203
+ __${name.value}_debug "Join the equal sign flag back to the completion value"
156
204
  $_.Name = $Flag + "=" + $_.Name
157
205
  }
158
206
  }
@@ -163,7 +211,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
163
211
  }
164
212
 
165
213
  if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
166
- __${p.value}_debug "ShellCompDirectiveNoFileComp is called"
214
+ __${name.value}_debug "ShellCompDirectiveNoFileComp is called"
167
215
 
168
216
  if ($Values.Length -eq 0) {
169
217
  # Just print an empty string here so the
@@ -177,7 +225,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
177
225
 
178
226
  # Get the current mode
179
227
  $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
180
- __${p.value}_debug "Mode: $Mode"
228
+ __${name.value}_debug "Mode: $Mode"
181
229
 
182
230
  $Values | ForEach-Object {
183
231
 
@@ -202,10 +250,10 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
202
250
  "Complete" {
203
251
 
204
252
  if ($Values.Length -eq 1) {
205
- __${p.value}_debug "Only one completion left"
253
+ __${name.value}_debug "Only one completion left"
206
254
 
207
255
  # insert space after value
208
- [System.Management.Automation.CompletionResult]::new($($comp.Name | __${p.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
256
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
209
257
 
210
258
  } else {
211
259
  # Add the proper number of spaces to align the descriptions
@@ -229,7 +277,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
229
277
  # insert space after value
230
278
  # MenuComplete will automatically show the ToolTip of
231
279
  # the highlighted value at the bottom of the suggestions.
232
- [System.Management.Automation.CompletionResult]::new($($comp.Name | __${p.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
280
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
233
281
  }
234
282
 
235
283
  # TabCompleteNext and in case we get something unknown
@@ -237,14 +285,22 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
237
285
  # Like MenuComplete but we don't want to add a space here because
238
286
  # the user need to press space anyway to get the completion.
239
287
  # Description will not be shown because that's not possible with TabCompleteNext
240
- [System.Management.Automation.CompletionResult]::new($($comp.Name | __${p.value}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
288
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name.value}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
241
289
  }
242
290
  }
243
291
  }
244
292
  }
245
293
 
246
- Register-ArgumentCompleter -CommandName '${f.value}' -ScriptBlock $__${p.value}CompleterBlock
247
- \`; `}}),(0,n.createComponent)(o.Spacing,{}),(0,n.createComponent)(a.VarDeclaration,{export:!0,const:!0,name:`SHELL_COMPLETIONS_DISPLAY`,initializer:i.code` SHELL_COMPLETIONS.split("\\n").map(line => {
294
+ Register-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${name.value}CompleterBlock
295
+ \`; `;
296
+ }
297
+ }),
298
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
299
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
300
+ "export": true,
301
+ "const": true,
302
+ name: "SHELL_COMPLETIONS_DISPLAY",
303
+ initializer: _alloy_js_core.code` SHELL_COMPLETIONS.split("\\n").map(line => {
248
304
  if (!line.trim()) {
249
305
  return "";
250
306
  }
@@ -265,4 +321,12 @@ Register-ArgumentCompleter -CommandName '${f.value}' -ScriptBlock $__${p.value}C
265
321
  .replaceAll(/\\$?__\\w/g, bold(magentaBright("$&")))
266
322
  .replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
267
323
 
268
- }).join("\\n"); `})]}})}exports.PowerShellCompletionsShared=d;
324
+ }).join("\\n"); `
325
+ })
326
+ ];
327
+ }
328
+ });
329
+ }
330
+
331
+ //#endregion
332
+ exports.PowerShellCompletionsShared = PowerShellCompletionsShared;
@@ -1,10 +1,8 @@
1
- import * as _$_alloy_js_core0 from "@alloy-js/core";
2
-
3
1
  //#region src/components/powershell-shared.d.ts
4
2
  /**
5
3
  * The PowerShell Completions generation for the Shell Shock project.
6
4
  */
7
- declare function PowerShellCompletionsShared(): _$_alloy_js_core0.Children;
5
+ declare function PowerShellCompletionsShared(): import("@alloy-js/core").Children;
8
6
  //#endregion
9
7
  export { PowerShellCompletionsShared };
10
8
  //# sourceMappingURL=powershell-shared.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"powershell-shared.d.cts","names":[],"sources":["../../src/components/powershell-shared.tsx"],"mappings":";;;;;;iBAiCgB,2BAAA,CAAA,GAA2B,iBAAA,CAAA,QAAA"}
1
+ {"version":3,"file":"powershell-shared.d.cts","names":[],"sources":["../../src/components/powershell-shared.tsx"],"mappings":";;AAiCA;;iBAAgB,2BAAA,6BAA2B,QAAA"}
@@ -1,10 +1,8 @@
1
- import * as _$_alloy_js_core0 from "@alloy-js/core";
2
-
3
1
  //#region src/components/powershell-shared.d.ts
4
2
  /**
5
3
  * The PowerShell Completions generation for the Shell Shock project.
6
4
  */
7
- declare function PowerShellCompletionsShared(): _$_alloy_js_core0.Children;
5
+ declare function PowerShellCompletionsShared(): import("@alloy-js/core").Children;
8
6
  //#endregion
9
7
  export { PowerShellCompletionsShared };
10
8
  //# sourceMappingURL=powershell-shared.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"powershell-shared.d.mts","names":[],"sources":["../../src/components/powershell-shared.tsx"],"mappings":";;;;;;iBAiCgB,2BAAA,CAAA,GAA2B,iBAAA,CAAA,QAAA"}
1
+ {"version":3,"file":"powershell-shared.d.mts","names":[],"sources":["../../src/components/powershell-shared.tsx"],"mappings":""}
@@ -1,17 +1,64 @@
1
- import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{CompletionDirective as t}from"../helpers/completion-directive-constants.mjs";import"../helpers/index.mjs";import{createComponent as n}from"@alloy-js/core/jsx-runtime";import{getAppBin as r,getAppTitle as i}from"@shell-shock/core/plugin-utils";import{code as a,computed as o}from"@alloy-js/core";import{VarDeclaration as s}from"@alloy-js/typescript";import{Spacing as c}from"@powerlines/plugin-alloy/core";import{usePowerlines as l}from"@powerlines/plugin-alloy/core/contexts/context";import{TypescriptFile as u}from"@powerlines/plugin-alloy/typescript";import{joinPaths as d}from"@stryke/path";import{camelCase as f}from"@stryke/string-format/camel-case";function p(){let p=l(),m=o(()=>r(p)),h=o(()=>f(m.value));return n(u,{get path(){return d(p.entryPath,`completions`,`powershell`,`shared.ts`)},builtinImports:{console:[`white`,`green`,`red`,`bold`,`cyan`,`gray`,`magenta`,`magentaBright`,`greenBright`,`redBright`,`cyanBright`,`dim`]},get children(){return[n(c,{}),n(s,{const:!0,export:!0,name:`SHELL_COMPLETIONS`,get initializer(){return a` \`# powershell completion for ${i(p)}
1
+ import { EXEC_COMMAND } from "../helpers/complete-command.mjs";
2
+ import { CompletionDirective } from "../helpers/completion-directive-constants.mjs";
3
+ import "../helpers/index.mjs";
4
+ import { createComponent } from "@alloy-js/core/jsx-runtime";
5
+ import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
6
+ import { code, computed } from "@alloy-js/core";
7
+ import { VarDeclaration } from "@alloy-js/typescript";
8
+ import { Spacing } from "@powerlines/plugin-alloy/core";
9
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
10
+ import { TypescriptFile } from "@powerlines/plugin-alloy/typescript";
11
+ import { joinPaths } from "@stryke/path";
12
+ import { camelCase } from "@stryke/string-format/camel-case";
13
+
14
+ //#region src/components/powershell-shared.tsx
15
+ /**
16
+ * The PowerShell Completions generation for the Shell Shock project.
17
+ */
18
+ function PowerShellCompletionsShared() {
19
+ const context = usePowerlines();
20
+ const bin = computed(() => getAppBin(context));
21
+ const name = computed(() => camelCase(bin.value));
22
+ return createComponent(TypescriptFile, {
23
+ get path() {
24
+ return joinPaths(context.entryPath, "completions", "powershell", "shared.ts");
25
+ },
26
+ builtinImports: { console: [
27
+ "white",
28
+ "green",
29
+ "red",
30
+ "bold",
31
+ "cyan",
32
+ "gray",
33
+ "magenta",
34
+ "magentaBright",
35
+ "greenBright",
36
+ "redBright",
37
+ "cyanBright",
38
+ "dim"
39
+ ] },
40
+ get children() {
41
+ return [
42
+ createComponent(Spacing, {}),
43
+ createComponent(VarDeclaration, {
44
+ "const": true,
45
+ "export": true,
46
+ name: "SHELL_COMPLETIONS",
47
+ get initializer() {
48
+ return code` \`# powershell completion for ${getAppTitle(context)}
2
49
 
3
50
  [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
4
- function __${h.value}_debug {
51
+ function __${name.value}_debug {
5
52
  if ($env:BASH_COMP_DEBUG_FILE) {
6
53
  "$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
7
54
  }
8
55
  }
9
56
 
10
- filter __${h.value}_escapeStringWithSpecialChars {
57
+ filter __${name.value}_escapeStringWithSpecialChars {
11
58
  $_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\\\`$&'
12
59
  }
13
60
 
14
- [scriptblock]$__${h.value}CompleterBlock = {
61
+ [scriptblock]$__${name.value}CompleterBlock = {
15
62
  param(
16
63
  $WordToComplete,
17
64
  $CommandAst,
@@ -22,9 +69,9 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
22
69
  $Command = $CommandAst.CommandElements
23
70
  $Command = "$Command"
24
71
 
25
- __${h.value}_debug ""
26
- __${h.value}_debug "========= starting completion logic =========="
27
- __${h.value}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
72
+ __${name.value}_debug ""
73
+ __${name.value}_debug "========= starting completion logic =========="
74
+ __${name.value}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
28
75
 
29
76
  # The user could have moved the cursor backwards on the command-line.
30
77
  # We need to trigger completion from the $CursorPosition location, so we need
@@ -34,24 +81,24 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
34
81
  if ($Command.Length -gt $CursorPosition) {
35
82
  $Command = $Command.Substring(0, $CursorPosition)
36
83
  }
37
- __${h.value}_debug "Truncated command: $Command"
84
+ __${name.value}_debug "Truncated command: $Command"
38
85
 
39
- $ShellCompDirectiveError=${t.CompletionDirectiveError}
40
- $ShellCompDirectiveNoSpace=${t.CompletionDirectiveNoSpace}
41
- $ShellCompDirectiveNoFileComp=${t.CompletionDirectiveNoFileComp}
42
- $ShellCompDirectiveFilterFileExt=${t.CompletionDirectiveFilterFileExt}
43
- $ShellCompDirectiveFilterDirs=${t.CompletionDirectiveFilterDirs}
44
- $ShellCompDirectiveKeepOrder=${t.CompletionDirectiveKeepOrder}
86
+ $ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}
87
+ $ShellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}
88
+ $ShellCompDirectiveNoFileComp=${CompletionDirective.CompletionDirectiveNoFileComp}
89
+ $ShellCompDirectiveFilterFileExt=${CompletionDirective.CompletionDirectiveFilterFileExt}
90
+ $ShellCompDirectiveFilterDirs=${CompletionDirective.CompletionDirectiveFilterDirs}
91
+ $ShellCompDirectiveKeepOrder=${CompletionDirective.CompletionDirectiveKeepOrder}
45
92
 
46
93
  # Prepare the command to request completions for the program.
47
94
  # Split the command at the first space to separate the program and arguments.
48
95
  $Program, $Arguments = $Command.Split(" ", 2)
49
96
 
50
97
  $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
51
- __${h.value}_debug "QuotedArgs: $QuotedArgs"
98
+ __${name.value}_debug "QuotedArgs: $QuotedArgs"
52
99
 
53
- $RequestComp = "& ${e} complete '--' $QuotedArgs"
54
- __${h.value}_debug "RequestComp: $RequestComp"
100
+ $RequestComp = "& ${EXEC_COMMAND} complete '--' $QuotedArgs"
101
+ __${name.value}_debug "RequestComp: $RequestComp"
55
102
 
56
103
  # we cannot use $WordToComplete because it
57
104
  # has the wrong values if the cursor was moved
@@ -59,13 +106,13 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
59
106
  if ($WordToComplete -ne "" ) {
60
107
  $WordToComplete = $Arguments.Split(" ")[-1]
61
108
  }
62
- __${h.value}_debug "New WordToComplete: $WordToComplete"
109
+ __${name.value}_debug "New WordToComplete: $WordToComplete"
63
110
 
64
111
 
65
112
  # Check for flag with equal sign
66
113
  $IsEqualFlag = ($WordToComplete -Like "--*=*" )
67
114
  if ( $IsEqualFlag ) {
68
- __${h.value}_debug "Completing equal sign flag"
115
+ __${name.value}_debug "Completing equal sign flag"
69
116
  # Remove the flag part
70
117
  $Flag, $WordToComplete = $WordToComplete.Split("=", 2)
71
118
  }
@@ -73,7 +120,7 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
73
120
  if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
74
121
  # If the last parameter is complete (there is a space following it)
75
122
  # We add an extra empty parameter so we can indicate this to the go method.
76
- __${h.value}_debug "Adding extra empty parameter"
123
+ __${name.value}_debug "Adding extra empty parameter"
77
124
  # PowerShell 7.2+ changed the way how the arguments are passed to executables,
78
125
  # so for pre-7.2 or when Legacy argument passing is enabled we need to use
79
126
  if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
@@ -86,7 +133,7 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
86
133
  }
87
134
  }
88
135
 
89
- __${h.value}_debug "Calling $RequestComp"
136
+ __${name.value}_debug "Calling $RequestComp"
90
137
  # First disable ActiveHelp which is not supported for Powershell
91
138
  $env:ActiveHelp = 0
92
139
 
@@ -100,14 +147,14 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
100
147
  # There is no directive specified
101
148
  $Directive = 0
102
149
  }
103
- __${h.value}_debug "The completion directive is: $Directive"
150
+ __${name.value}_debug "The completion directive is: $Directive"
104
151
 
105
152
  # remove directive (last element) from out
106
153
  $Out = $Out | Where-Object { $_ -ne $Out[-1] }
107
- __${h.value}_debug "The completions are: $Out"
154
+ __${name.value}_debug "The completions are: $Out"
108
155
  if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
109
156
  # Error code. No completion.
110
- __${h.value}_debug "Received error from custom completion go code"
157
+ __${name.value}_debug "Received error from custom completion go code"
111
158
  return
112
159
  }
113
160
 
@@ -115,7 +162,7 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
115
162
  [Array]$Values = $Out | ForEach-Object {
116
163
  # Split the output in name and description
117
164
  $Name, $Description = $_.Split("\\\`t", 2)
118
- __${h.value}_debug "Name: $Name Description: $Description"
165
+ __${name.value}_debug "Name: $Name Description: $Description"
119
166
 
120
167
  # Look for the longest completion so that we can format things nicely
121
168
  if ($Longest -lt $Name.Length) {
@@ -134,13 +181,13 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
134
181
  $Space = " "
135
182
  if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
136
183
  # remove the space here
137
- __${h.value}_debug "ShellCompDirectiveNoSpace is called"
184
+ __${name.value}_debug "ShellCompDirectiveNoSpace is called"
138
185
  $Space = ""
139
186
  }
140
187
 
141
188
  if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
142
189
  (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
143
- __${h.value}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
190
+ __${name.value}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
144
191
 
145
192
  # return here to prevent the completion of the extensions
146
193
  return
@@ -152,7 +199,7 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
152
199
 
153
200
  # Join the flag back if we have an equal sign flag
154
201
  if ( $IsEqualFlag ) {
155
- __${h.value}_debug "Join the equal sign flag back to the completion value"
202
+ __${name.value}_debug "Join the equal sign flag back to the completion value"
156
203
  $_.Name = $Flag + "=" + $_.Name
157
204
  }
158
205
  }
@@ -163,7 +210,7 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
163
210
  }
164
211
 
165
212
  if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
166
- __${h.value}_debug "ShellCompDirectiveNoFileComp is called"
213
+ __${name.value}_debug "ShellCompDirectiveNoFileComp is called"
167
214
 
168
215
  if ($Values.Length -eq 0) {
169
216
  # Just print an empty string here so the
@@ -177,7 +224,7 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
177
224
 
178
225
  # Get the current mode
179
226
  $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
180
- __${h.value}_debug "Mode: $Mode"
227
+ __${name.value}_debug "Mode: $Mode"
181
228
 
182
229
  $Values | ForEach-Object {
183
230
 
@@ -202,10 +249,10 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
202
249
  "Complete" {
203
250
 
204
251
  if ($Values.Length -eq 1) {
205
- __${h.value}_debug "Only one completion left"
252
+ __${name.value}_debug "Only one completion left"
206
253
 
207
254
  # insert space after value
208
- [System.Management.Automation.CompletionResult]::new($($comp.Name | __${h.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
255
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
209
256
 
210
257
  } else {
211
258
  # Add the proper number of spaces to align the descriptions
@@ -229,7 +276,7 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
229
276
  # insert space after value
230
277
  # MenuComplete will automatically show the ToolTip of
231
278
  # the highlighted value at the bottom of the suggestions.
232
- [System.Management.Automation.CompletionResult]::new($($comp.Name | __${h.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
279
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
233
280
  }
234
281
 
235
282
  # TabCompleteNext and in case we get something unknown
@@ -237,14 +284,22 @@ import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{Completion
237
284
  # Like MenuComplete but we don't want to add a space here because
238
285
  # the user need to press space anyway to get the completion.
239
286
  # Description will not be shown because that's not possible with TabCompleteNext
240
- [System.Management.Automation.CompletionResult]::new($($comp.Name | __${h.value}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
287
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name.value}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
241
288
  }
242
289
  }
243
290
  }
244
291
  }
245
292
 
246
- Register-ArgumentCompleter -CommandName '${m.value}' -ScriptBlock $__${h.value}CompleterBlock
247
- \`; `}}),n(c,{}),n(s,{export:!0,const:!0,name:`SHELL_COMPLETIONS_DISPLAY`,initializer:a` SHELL_COMPLETIONS.split("\\n").map(line => {
293
+ Register-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${name.value}CompleterBlock
294
+ \`; `;
295
+ }
296
+ }),
297
+ createComponent(Spacing, {}),
298
+ createComponent(VarDeclaration, {
299
+ "export": true,
300
+ "const": true,
301
+ name: "SHELL_COMPLETIONS_DISPLAY",
302
+ initializer: code` SHELL_COMPLETIONS.split("\\n").map(line => {
248
303
  if (!line.trim()) {
249
304
  return "";
250
305
  }
@@ -265,5 +320,13 @@ Register-ArgumentCompleter -CommandName '${m.value}' -ScriptBlock $__${h.value}C
265
320
  .replaceAll(/\\$?__\\w/g, bold(magentaBright("$&")))
266
321
  .replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
267
322
 
268
- }).join("\\n"); `})]}})}export{p as PowerShellCompletionsShared};
323
+ }).join("\\n"); `
324
+ })
325
+ ];
326
+ }
327
+ });
328
+ }
329
+
330
+ //#endregion
331
+ export { PowerShellCompletionsShared };
269
332
  //# sourceMappingURL=powershell-shared.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"powershell-shared.mjs","names":[],"sources":["../../src/components/powershell-shared.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The PowerShell Completions generation for the Shell Shock project.\n */\nexport function PowerShellCompletionsShared() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n const name = computed(() => camelCase(bin.value));\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"powershell\",\n \"shared.ts\"\n )}\n builtinImports={{\n console: [\n \"white\",\n \"green\",\n \"red\",\n \"bold\",\n \"cyan\",\n \"gray\",\n \"magenta\",\n \"magentaBright\",\n \"greenBright\",\n \"redBright\",\n \"cyanBright\",\n \"dim\"\n ]\n }}>\n <Spacing />\n <VarDeclaration\n const\n export\n name=\"SHELL_COMPLETIONS\"\n initializer={code` \\`# powershell completion for ${getAppTitle(context)}\n\n [Console]::OutputEncoding = [System.Text.Encoding]::UTF8\n function __${name.value}_debug {\n if ($env:BASH_COMP_DEBUG_FILE) {\n \"$args\" | Out-File -Append -FilePath \"$env:BASH_COMP_DEBUG_FILE\"\n }\n }\n\n filter __${name.value}_escapeStringWithSpecialChars {\n $_ -replace '\\\\s|#|@|\\\\$|;|,|''|\\\\{|\\\\}|\\\\(|\\\\)|\"|\\\\||<|>|&','\\\\\\`$&'\n }\n\n[scriptblock]$__${name.value}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 __${name.value}_debug \"\"\n __${name.value}_debug \"========= starting completion logic ==========\"\n __${name.value}_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 __${name.value}_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 __${name.value}_debug \"QuotedArgs: $QuotedArgs\"\n\n $RequestComp = \"& ${EXEC_COMMAND} complete '--' $QuotedArgs\"\n __${name.value}_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 __${name.value}_debug \"New WordToComplete: $WordToComplete\"\n\n\n # Check for flag with equal sign\n $IsEqualFlag = ($WordToComplete -Like \"--*=*\" )\n if ( $IsEqualFlag ) {\n __${name.value}_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 __${name.value}_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 __${name.value}_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 __${name.value}_debug \"The completion directive is: $Directive\"\n\n # remove directive (last element) from out\n $Out = $Out | Where-Object { $_ -ne $Out[-1] }\n __${name.value}_debug \"The completions are: $Out\"\n if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {\n # Error code. No completion.\n __${name.value}_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 __${name.value}_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 __${name.value}_debug \"ShellCompDirectiveNoSpace is called\"\n $Space = \"\"\n }\n\n if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or\n (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {\n __${\n name.value\n }_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 __${\n name.value\n }_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 __${name.value}_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 __${name.value}_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 __${name.value}_debug \"Only one completion left\"\n\n # insert space after value\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${\n name.value\n }_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 | __${\n name.value\n }_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 | __${\n name.value\n }_escapeStringWithSpecialChars), \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n }\n}\n\nRegister-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${\n name.value\n }CompleterBlock\n\\`; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS_DISPLAY\"\n initializer={code` SHELL_COMPLETIONS.split(\"\\\\n\").map(line => {\n if (!line.trim()) {\n return \"\";\n }\n if (line.trim().startsWith(\"#\")) {\n return \\`\\${dim(line)}\\`;\n }\n\n return white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, green(\"$&\"))\n .replaceAll(/\\\\\".*\\\\\"/g, cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|::new|::OutputEncoding|::UTF8)/g, bold(gray(\"$&\")))\n .replaceAll(/(switch|complete)\\\\s+/g, green(\"$&\"))\n .replaceAll(/(?<=(switch|complete)\\\\s+)\\\\w/g, bold(greenBright(\"$&\")))\n .replaceAll(/(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\\\w+)\\\\s+/g, red(\"$&\"))\n .replaceAll(/(?<=(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\\\w+)\\\\s+)\\\\w/g, bold(redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, bold(cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, green(\"$&\"))\n .replaceAll(/\\\\$?__\\\\w/g, bold(magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, bold(magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":"qtBAgCA,SAAE,GAAA,CACF,IAAO,EAAS,GAAA,CACR,EAAA,MAAU,EAAc,EAAA,CAAA,qBAE9B,OAAM,EAAmB,EAAY,CACrC,IAAM,MAAO,+DAGX,eAAC,CACC,QAAM,CAAA,QAAS,QAAA,MAAA,OAAA,OAAA,OAAA,UAAA,gBAAA,cAAA,YAAA,aAAA,MAAA,CAChB,CACD,IAAI,UAAC,CACH,MAAG,CAAA,EAAW,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACZ,MAAQ,GACT,OAAA,GACD,KAAA,oBACE,IAAA,aAAS,CACP,MAAO,EAAA,kCAAA,EAAA,EAAA,CAAA;;;iBAGD,EAAA,MAAA;;;;;;eAML,EAAS,MAAC;;;;kBAIb,EAAA,MAAA;;;;;;;;;;;QAWA,EAAK,MAAM;QACX,EAAA,MAAA;QACJ,EAAA,MAAA;;;;;;;;;;QAUI,EAAK,MAAA;;;iCAGiB,EAAuB,2BAAC;oCAC3B,EAAA,8BAAA;uCACH,EAAA,iCAAA;;mCAEG,EAAA,6BAAA;;;;;;;QAOrB,EAAK,MAAQ;;wBAEK,EAAK;QACrB,EAAC,MAAU;;;;;;;;QAQf,EAAA,MAAA;;;;;;YAMA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;QAqBI,EAAK,MAAM;;;;;;;;;;;;;;QAcX,EAAI,MAAK;;;;QAIT,EAAK,MAAC;;;YAGF,EAAE,MAAA;;;;;;;;YAQL,EAAA,MAAa;;;;;;;;;;;;;;;;;;;YAmBV,EAAK,MAAM;;;;;;YAMb,EAAM,MAAI;;;;;;;;;;;;gBAYP,EAAA,MAAc;;;;;;;;;;;YAWvB,EAAA,MAAA;;;;;;;;;;;;;;QAcI,EAAG,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;wBAyBL,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;wFA2BO,EAAA,MAAA;;;;;;;;wFAQQ,EAAA,MAAA;;;;;;2CAMgB,EAAI,MAAK,oBAAA,EAAA,MAAA;OAG7C,CAAC,CAAE,EAAkB,EAAS,EAAC,CAAA,CAAA,EAAqB,EAAgB,CACnE,OAAU,GACV,MAAS,GACT,KAAM,4BACN,YAAa,CAAI;;;;;;;;;;;;;;;;;;;;;0BAsBlB,CAAC,CAAC,EAEN,CAAC"}
1
+ {"version":3,"file":"powershell-shared.mjs","names":[],"sources":[],"mappings":""}