@shell-shock/plugin-completions 0.4.15 → 0.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/bash-config-command.cjs +6 -120
- package/dist/components/bash-config-command.mjs +6 -119
- package/dist/components/bash-config-command.mjs.map +1 -1
- package/dist/components/bash-script-command.cjs +5 -105
- package/dist/components/bash-script-command.mjs +5 -104
- package/dist/components/bash-script-command.mjs.map +1 -1
- package/dist/components/bash-shared.cjs +13 -77
- package/dist/components/bash-shared.mjs +13 -76
- package/dist/components/bash-shared.mjs.map +1 -1
- package/dist/components/fish-config-command.cjs +6 -120
- package/dist/components/fish-config-command.mjs +6 -119
- package/dist/components/fish-config-command.mjs.map +1 -1
- package/dist/components/fish-script-command.cjs +4 -104
- package/dist/components/fish-script-command.mjs +4 -103
- package/dist/components/fish-script-command.mjs.map +1 -1
- package/dist/components/fish-shared.cjs +77 -141
- package/dist/components/fish-shared.mjs +77 -140
- package/dist/components/fish-shared.mjs.map +1 -1
- package/dist/components/index.cjs +1 -26
- package/dist/components/index.mjs +1 -14
- package/dist/components/powershell-config-command.cjs +6 -116
- package/dist/components/powershell-config-command.mjs +6 -115
- package/dist/components/powershell-config-command.mjs.map +1 -1
- package/dist/components/powershell-script-command.cjs +4 -104
- package/dist/components/powershell-script-command.mjs +4 -103
- package/dist/components/powershell-script-command.mjs.map +1 -1
- package/dist/components/powershell-shared.cjs +37 -101
- package/dist/components/powershell-shared.mjs +37 -100
- package/dist/components/powershell-shared.mjs.map +1 -1
- package/dist/components/zsh-config-command.cjs +6 -120
- package/dist/components/zsh-config-command.mjs +6 -119
- package/dist/components/zsh-config-command.mjs.map +1 -1
- package/dist/components/zsh-script-command.cjs +6 -108
- package/dist/components/zsh-script-command.mjs +6 -107
- package/dist/components/zsh-script-command.mjs.map +1 -1
- package/dist/components/zsh-shared.cjs +42 -106
- package/dist/components/zsh-shared.mjs +42 -105
- package/dist/components/zsh-shared.mjs.map +1 -1
- package/dist/helpers/complete-command.cjs +1 -10
- package/dist/helpers/complete-command.mjs +1 -8
- package/dist/helpers/complete-command.mjs.map +1 -1
- package/dist/helpers/completion-directive-constants.cjs +1 -16
- package/dist/helpers/completion-directive-constants.mjs +1 -14
- package/dist/helpers/completion-directive-constants.mjs.map +1 -1
- package/dist/helpers/index.cjs +1 -6
- package/dist/helpers/index.mjs +1 -4
- package/dist/index.cjs +1 -303
- package/dist/index.mjs +1 -301
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +1 -4
- package/dist/types/index.mjs +1 -3
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/shell-type.cjs +1 -12
- package/dist/types/shell-type.mjs +1 -10
- package/dist/types/shell-type.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -1,65 +1,17 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
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)}
|
|
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)}
|
|
50
2
|
|
|
51
3
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
52
|
-
function __${
|
|
4
|
+
function __${p.value}_debug {
|
|
53
5
|
if ($env:BASH_COMP_DEBUG_FILE) {
|
|
54
6
|
"$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
|
|
55
7
|
}
|
|
56
8
|
}
|
|
57
9
|
|
|
58
|
-
filter __${
|
|
10
|
+
filter __${p.value}_escapeStringWithSpecialChars {
|
|
59
11
|
$_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\\\`$&'
|
|
60
12
|
}
|
|
61
13
|
|
|
62
|
-
[scriptblock]$__${
|
|
14
|
+
[scriptblock]$__${p.value}CompleterBlock = {
|
|
63
15
|
param(
|
|
64
16
|
$WordToComplete,
|
|
65
17
|
$CommandAst,
|
|
@@ -70,9 +22,9 @@ function PowerShellCompletionsShared() {
|
|
|
70
22
|
$Command = $CommandAst.CommandElements
|
|
71
23
|
$Command = "$Command"
|
|
72
24
|
|
|
73
|
-
__${
|
|
74
|
-
__${
|
|
75
|
-
__${
|
|
25
|
+
__${p.value}_debug ""
|
|
26
|
+
__${p.value}_debug "========= starting completion logic =========="
|
|
27
|
+
__${p.value}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
|
|
76
28
|
|
|
77
29
|
# The user could have moved the cursor backwards on the command-line.
|
|
78
30
|
# We need to trigger completion from the $CursorPosition location, so we need
|
|
@@ -82,24 +34,24 @@ function PowerShellCompletionsShared() {
|
|
|
82
34
|
if ($Command.Length -gt $CursorPosition) {
|
|
83
35
|
$Command = $Command.Substring(0, $CursorPosition)
|
|
84
36
|
}
|
|
85
|
-
__${
|
|
37
|
+
__${p.value}_debug "Truncated command: $Command"
|
|
86
38
|
|
|
87
|
-
$ShellCompDirectiveError=${
|
|
88
|
-
$ShellCompDirectiveNoSpace=${
|
|
89
|
-
$ShellCompDirectiveNoFileComp=${
|
|
90
|
-
$ShellCompDirectiveFilterFileExt=${
|
|
91
|
-
$ShellCompDirectiveFilterDirs=${
|
|
92
|
-
$ShellCompDirectiveKeepOrder=${
|
|
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}
|
|
93
45
|
|
|
94
46
|
# Prepare the command to request completions for the program.
|
|
95
47
|
# Split the command at the first space to separate the program and arguments.
|
|
96
48
|
$Program, $Arguments = $Command.Split(" ", 2)
|
|
97
49
|
|
|
98
50
|
$QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
|
|
99
|
-
__${
|
|
51
|
+
__${p.value}_debug "QuotedArgs: $QuotedArgs"
|
|
100
52
|
|
|
101
|
-
$RequestComp = "& ${
|
|
102
|
-
__${
|
|
53
|
+
$RequestComp = "& ${e.EXEC_COMMAND} complete '--' $QuotedArgs"
|
|
54
|
+
__${p.value}_debug "RequestComp: $RequestComp"
|
|
103
55
|
|
|
104
56
|
# we cannot use $WordToComplete because it
|
|
105
57
|
# has the wrong values if the cursor was moved
|
|
@@ -107,13 +59,13 @@ function PowerShellCompletionsShared() {
|
|
|
107
59
|
if ($WordToComplete -ne "" ) {
|
|
108
60
|
$WordToComplete = $Arguments.Split(" ")[-1]
|
|
109
61
|
}
|
|
110
|
-
__${
|
|
62
|
+
__${p.value}_debug "New WordToComplete: $WordToComplete"
|
|
111
63
|
|
|
112
64
|
|
|
113
65
|
# Check for flag with equal sign
|
|
114
66
|
$IsEqualFlag = ($WordToComplete -Like "--*=*" )
|
|
115
67
|
if ( $IsEqualFlag ) {
|
|
116
|
-
__${
|
|
68
|
+
__${p.value}_debug "Completing equal sign flag"
|
|
117
69
|
# Remove the flag part
|
|
118
70
|
$Flag, $WordToComplete = $WordToComplete.Split("=", 2)
|
|
119
71
|
}
|
|
@@ -121,7 +73,7 @@ function PowerShellCompletionsShared() {
|
|
|
121
73
|
if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
|
|
122
74
|
# If the last parameter is complete (there is a space following it)
|
|
123
75
|
# We add an extra empty parameter so we can indicate this to the go method.
|
|
124
|
-
__${
|
|
76
|
+
__${p.value}_debug "Adding extra empty parameter"
|
|
125
77
|
# PowerShell 7.2+ changed the way how the arguments are passed to executables,
|
|
126
78
|
# so for pre-7.2 or when Legacy argument passing is enabled we need to use
|
|
127
79
|
if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
|
|
@@ -134,7 +86,7 @@ function PowerShellCompletionsShared() {
|
|
|
134
86
|
}
|
|
135
87
|
}
|
|
136
88
|
|
|
137
|
-
__${
|
|
89
|
+
__${p.value}_debug "Calling $RequestComp"
|
|
138
90
|
# First disable ActiveHelp which is not supported for Powershell
|
|
139
91
|
$env:ActiveHelp = 0
|
|
140
92
|
|
|
@@ -148,14 +100,14 @@ function PowerShellCompletionsShared() {
|
|
|
148
100
|
# There is no directive specified
|
|
149
101
|
$Directive = 0
|
|
150
102
|
}
|
|
151
|
-
__${
|
|
103
|
+
__${p.value}_debug "The completion directive is: $Directive"
|
|
152
104
|
|
|
153
105
|
# remove directive (last element) from out
|
|
154
106
|
$Out = $Out | Where-Object { $_ -ne $Out[-1] }
|
|
155
|
-
__${
|
|
107
|
+
__${p.value}_debug "The completions are: $Out"
|
|
156
108
|
if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
|
|
157
109
|
# Error code. No completion.
|
|
158
|
-
__${
|
|
110
|
+
__${p.value}_debug "Received error from custom completion go code"
|
|
159
111
|
return
|
|
160
112
|
}
|
|
161
113
|
|
|
@@ -163,7 +115,7 @@ function PowerShellCompletionsShared() {
|
|
|
163
115
|
[Array]$Values = $Out | ForEach-Object {
|
|
164
116
|
# Split the output in name and description
|
|
165
117
|
$Name, $Description = $_.Split("\\\`t", 2)
|
|
166
|
-
__${
|
|
118
|
+
__${p.value}_debug "Name: $Name Description: $Description"
|
|
167
119
|
|
|
168
120
|
# Look for the longest completion so that we can format things nicely
|
|
169
121
|
if ($Longest -lt $Name.Length) {
|
|
@@ -182,13 +134,13 @@ function PowerShellCompletionsShared() {
|
|
|
182
134
|
$Space = " "
|
|
183
135
|
if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
|
|
184
136
|
# remove the space here
|
|
185
|
-
__${
|
|
137
|
+
__${p.value}_debug "ShellCompDirectiveNoSpace is called"
|
|
186
138
|
$Space = ""
|
|
187
139
|
}
|
|
188
140
|
|
|
189
141
|
if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
|
|
190
142
|
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
|
|
191
|
-
__${
|
|
143
|
+
__${p.value}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
|
|
192
144
|
|
|
193
145
|
# return here to prevent the completion of the extensions
|
|
194
146
|
return
|
|
@@ -200,7 +152,7 @@ function PowerShellCompletionsShared() {
|
|
|
200
152
|
|
|
201
153
|
# Join the flag back if we have an equal sign flag
|
|
202
154
|
if ( $IsEqualFlag ) {
|
|
203
|
-
__${
|
|
155
|
+
__${p.value}_debug "Join the equal sign flag back to the completion value"
|
|
204
156
|
$_.Name = $Flag + "=" + $_.Name
|
|
205
157
|
}
|
|
206
158
|
}
|
|
@@ -211,7 +163,7 @@ function PowerShellCompletionsShared() {
|
|
|
211
163
|
}
|
|
212
164
|
|
|
213
165
|
if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
|
|
214
|
-
__${
|
|
166
|
+
__${p.value}_debug "ShellCompDirectiveNoFileComp is called"
|
|
215
167
|
|
|
216
168
|
if ($Values.Length -eq 0) {
|
|
217
169
|
# Just print an empty string here so the
|
|
@@ -225,7 +177,7 @@ function PowerShellCompletionsShared() {
|
|
|
225
177
|
|
|
226
178
|
# Get the current mode
|
|
227
179
|
$Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
|
|
228
|
-
__${
|
|
180
|
+
__${p.value}_debug "Mode: $Mode"
|
|
229
181
|
|
|
230
182
|
$Values | ForEach-Object {
|
|
231
183
|
|
|
@@ -250,10 +202,10 @@ function PowerShellCompletionsShared() {
|
|
|
250
202
|
"Complete" {
|
|
251
203
|
|
|
252
204
|
if ($Values.Length -eq 1) {
|
|
253
|
-
__${
|
|
205
|
+
__${p.value}_debug "Only one completion left"
|
|
254
206
|
|
|
255
207
|
# insert space after value
|
|
256
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${
|
|
208
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${p.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
257
209
|
|
|
258
210
|
} else {
|
|
259
211
|
# Add the proper number of spaces to align the descriptions
|
|
@@ -277,7 +229,7 @@ function PowerShellCompletionsShared() {
|
|
|
277
229
|
# insert space after value
|
|
278
230
|
# MenuComplete will automatically show the ToolTip of
|
|
279
231
|
# the highlighted value at the bottom of the suggestions.
|
|
280
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${
|
|
232
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${p.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
281
233
|
}
|
|
282
234
|
|
|
283
235
|
# TabCompleteNext and in case we get something unknown
|
|
@@ -285,22 +237,14 @@ function PowerShellCompletionsShared() {
|
|
|
285
237
|
# Like MenuComplete but we don't want to add a space here because
|
|
286
238
|
# the user need to press space anyway to get the completion.
|
|
287
239
|
# Description will not be shown because that's not possible with TabCompleteNext
|
|
288
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${
|
|
240
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${p.value}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
289
241
|
}
|
|
290
242
|
}
|
|
291
243
|
}
|
|
292
244
|
}
|
|
293
245
|
|
|
294
|
-
Register-ArgumentCompleter -CommandName '${
|
|
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 => {
|
|
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 => {
|
|
304
248
|
if (!line.trim()) {
|
|
305
249
|
return "";
|
|
306
250
|
}
|
|
@@ -321,12 +265,4 @@ Register-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${name.va
|
|
|
321
265
|
.replaceAll(/\\$?__\\w/g, bold(magentaBright("$&")))
|
|
322
266
|
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
323
267
|
|
|
324
|
-
}).join("\\n"); `
|
|
325
|
-
})
|
|
326
|
-
];
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
//#endregion
|
|
332
|
-
exports.PowerShellCompletionsShared = PowerShellCompletionsShared;
|
|
268
|
+
}).join("\\n"); `})]}})}exports.PowerShellCompletionsShared=d;
|
|
@@ -1,64 +1,17 @@
|
|
|
1
|
-
import
|
|
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)}
|
|
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)}
|
|
49
2
|
|
|
50
3
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
51
|
-
function __${
|
|
4
|
+
function __${h.value}_debug {
|
|
52
5
|
if ($env:BASH_COMP_DEBUG_FILE) {
|
|
53
6
|
"$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
|
|
54
7
|
}
|
|
55
8
|
}
|
|
56
9
|
|
|
57
|
-
filter __${
|
|
10
|
+
filter __${h.value}_escapeStringWithSpecialChars {
|
|
58
11
|
$_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\\\`$&'
|
|
59
12
|
}
|
|
60
13
|
|
|
61
|
-
[scriptblock]$__${
|
|
14
|
+
[scriptblock]$__${h.value}CompleterBlock = {
|
|
62
15
|
param(
|
|
63
16
|
$WordToComplete,
|
|
64
17
|
$CommandAst,
|
|
@@ -69,9 +22,9 @@ function PowerShellCompletionsShared() {
|
|
|
69
22
|
$Command = $CommandAst.CommandElements
|
|
70
23
|
$Command = "$Command"
|
|
71
24
|
|
|
72
|
-
__${
|
|
73
|
-
__${
|
|
74
|
-
__${
|
|
25
|
+
__${h.value}_debug ""
|
|
26
|
+
__${h.value}_debug "========= starting completion logic =========="
|
|
27
|
+
__${h.value}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
|
|
75
28
|
|
|
76
29
|
# The user could have moved the cursor backwards on the command-line.
|
|
77
30
|
# We need to trigger completion from the $CursorPosition location, so we need
|
|
@@ -81,24 +34,24 @@ function PowerShellCompletionsShared() {
|
|
|
81
34
|
if ($Command.Length -gt $CursorPosition) {
|
|
82
35
|
$Command = $Command.Substring(0, $CursorPosition)
|
|
83
36
|
}
|
|
84
|
-
__${
|
|
37
|
+
__${h.value}_debug "Truncated command: $Command"
|
|
85
38
|
|
|
86
|
-
$ShellCompDirectiveError=${
|
|
87
|
-
$ShellCompDirectiveNoSpace=${
|
|
88
|
-
$ShellCompDirectiveNoFileComp=${
|
|
89
|
-
$ShellCompDirectiveFilterFileExt=${
|
|
90
|
-
$ShellCompDirectiveFilterDirs=${
|
|
91
|
-
$ShellCompDirectiveKeepOrder=${
|
|
39
|
+
$ShellCompDirectiveError=${t.CompletionDirectiveError}
|
|
40
|
+
$ShellCompDirectiveNoSpace=${t.CompletionDirectiveNoSpace}
|
|
41
|
+
$ShellCompDirectiveNoFileComp=${t.CompletionDirectiveNoFileComp}
|
|
42
|
+
$ShellCompDirectiveFilterFileExt=${t.CompletionDirectiveFilterFileExt}
|
|
43
|
+
$ShellCompDirectiveFilterDirs=${t.CompletionDirectiveFilterDirs}
|
|
44
|
+
$ShellCompDirectiveKeepOrder=${t.CompletionDirectiveKeepOrder}
|
|
92
45
|
|
|
93
46
|
# Prepare the command to request completions for the program.
|
|
94
47
|
# Split the command at the first space to separate the program and arguments.
|
|
95
48
|
$Program, $Arguments = $Command.Split(" ", 2)
|
|
96
49
|
|
|
97
50
|
$QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
|
|
98
|
-
__${
|
|
51
|
+
__${h.value}_debug "QuotedArgs: $QuotedArgs"
|
|
99
52
|
|
|
100
|
-
$RequestComp = "& ${
|
|
101
|
-
__${
|
|
53
|
+
$RequestComp = "& ${e} complete '--' $QuotedArgs"
|
|
54
|
+
__${h.value}_debug "RequestComp: $RequestComp"
|
|
102
55
|
|
|
103
56
|
# we cannot use $WordToComplete because it
|
|
104
57
|
# has the wrong values if the cursor was moved
|
|
@@ -106,13 +59,13 @@ function PowerShellCompletionsShared() {
|
|
|
106
59
|
if ($WordToComplete -ne "" ) {
|
|
107
60
|
$WordToComplete = $Arguments.Split(" ")[-1]
|
|
108
61
|
}
|
|
109
|
-
__${
|
|
62
|
+
__${h.value}_debug "New WordToComplete: $WordToComplete"
|
|
110
63
|
|
|
111
64
|
|
|
112
65
|
# Check for flag with equal sign
|
|
113
66
|
$IsEqualFlag = ($WordToComplete -Like "--*=*" )
|
|
114
67
|
if ( $IsEqualFlag ) {
|
|
115
|
-
__${
|
|
68
|
+
__${h.value}_debug "Completing equal sign flag"
|
|
116
69
|
# Remove the flag part
|
|
117
70
|
$Flag, $WordToComplete = $WordToComplete.Split("=", 2)
|
|
118
71
|
}
|
|
@@ -120,7 +73,7 @@ function PowerShellCompletionsShared() {
|
|
|
120
73
|
if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
|
|
121
74
|
# If the last parameter is complete (there is a space following it)
|
|
122
75
|
# We add an extra empty parameter so we can indicate this to the go method.
|
|
123
|
-
__${
|
|
76
|
+
__${h.value}_debug "Adding extra empty parameter"
|
|
124
77
|
# PowerShell 7.2+ changed the way how the arguments are passed to executables,
|
|
125
78
|
# so for pre-7.2 or when Legacy argument passing is enabled we need to use
|
|
126
79
|
if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
|
|
@@ -133,7 +86,7 @@ function PowerShellCompletionsShared() {
|
|
|
133
86
|
}
|
|
134
87
|
}
|
|
135
88
|
|
|
136
|
-
__${
|
|
89
|
+
__${h.value}_debug "Calling $RequestComp"
|
|
137
90
|
# First disable ActiveHelp which is not supported for Powershell
|
|
138
91
|
$env:ActiveHelp = 0
|
|
139
92
|
|
|
@@ -147,14 +100,14 @@ function PowerShellCompletionsShared() {
|
|
|
147
100
|
# There is no directive specified
|
|
148
101
|
$Directive = 0
|
|
149
102
|
}
|
|
150
|
-
__${
|
|
103
|
+
__${h.value}_debug "The completion directive is: $Directive"
|
|
151
104
|
|
|
152
105
|
# remove directive (last element) from out
|
|
153
106
|
$Out = $Out | Where-Object { $_ -ne $Out[-1] }
|
|
154
|
-
__${
|
|
107
|
+
__${h.value}_debug "The completions are: $Out"
|
|
155
108
|
if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
|
|
156
109
|
# Error code. No completion.
|
|
157
|
-
__${
|
|
110
|
+
__${h.value}_debug "Received error from custom completion go code"
|
|
158
111
|
return
|
|
159
112
|
}
|
|
160
113
|
|
|
@@ -162,7 +115,7 @@ function PowerShellCompletionsShared() {
|
|
|
162
115
|
[Array]$Values = $Out | ForEach-Object {
|
|
163
116
|
# Split the output in name and description
|
|
164
117
|
$Name, $Description = $_.Split("\\\`t", 2)
|
|
165
|
-
__${
|
|
118
|
+
__${h.value}_debug "Name: $Name Description: $Description"
|
|
166
119
|
|
|
167
120
|
# Look for the longest completion so that we can format things nicely
|
|
168
121
|
if ($Longest -lt $Name.Length) {
|
|
@@ -181,13 +134,13 @@ function PowerShellCompletionsShared() {
|
|
|
181
134
|
$Space = " "
|
|
182
135
|
if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
|
|
183
136
|
# remove the space here
|
|
184
|
-
__${
|
|
137
|
+
__${h.value}_debug "ShellCompDirectiveNoSpace is called"
|
|
185
138
|
$Space = ""
|
|
186
139
|
}
|
|
187
140
|
|
|
188
141
|
if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
|
|
189
142
|
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
|
|
190
|
-
__${
|
|
143
|
+
__${h.value}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
|
|
191
144
|
|
|
192
145
|
# return here to prevent the completion of the extensions
|
|
193
146
|
return
|
|
@@ -199,7 +152,7 @@ function PowerShellCompletionsShared() {
|
|
|
199
152
|
|
|
200
153
|
# Join the flag back if we have an equal sign flag
|
|
201
154
|
if ( $IsEqualFlag ) {
|
|
202
|
-
__${
|
|
155
|
+
__${h.value}_debug "Join the equal sign flag back to the completion value"
|
|
203
156
|
$_.Name = $Flag + "=" + $_.Name
|
|
204
157
|
}
|
|
205
158
|
}
|
|
@@ -210,7 +163,7 @@ function PowerShellCompletionsShared() {
|
|
|
210
163
|
}
|
|
211
164
|
|
|
212
165
|
if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
|
|
213
|
-
__${
|
|
166
|
+
__${h.value}_debug "ShellCompDirectiveNoFileComp is called"
|
|
214
167
|
|
|
215
168
|
if ($Values.Length -eq 0) {
|
|
216
169
|
# Just print an empty string here so the
|
|
@@ -224,7 +177,7 @@ function PowerShellCompletionsShared() {
|
|
|
224
177
|
|
|
225
178
|
# Get the current mode
|
|
226
179
|
$Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
|
|
227
|
-
__${
|
|
180
|
+
__${h.value}_debug "Mode: $Mode"
|
|
228
181
|
|
|
229
182
|
$Values | ForEach-Object {
|
|
230
183
|
|
|
@@ -249,10 +202,10 @@ function PowerShellCompletionsShared() {
|
|
|
249
202
|
"Complete" {
|
|
250
203
|
|
|
251
204
|
if ($Values.Length -eq 1) {
|
|
252
|
-
__${
|
|
205
|
+
__${h.value}_debug "Only one completion left"
|
|
253
206
|
|
|
254
207
|
# insert space after value
|
|
255
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${
|
|
208
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${h.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
256
209
|
|
|
257
210
|
} else {
|
|
258
211
|
# Add the proper number of spaces to align the descriptions
|
|
@@ -276,7 +229,7 @@ function PowerShellCompletionsShared() {
|
|
|
276
229
|
# insert space after value
|
|
277
230
|
# MenuComplete will automatically show the ToolTip of
|
|
278
231
|
# the highlighted value at the bottom of the suggestions.
|
|
279
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${
|
|
232
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${h.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
280
233
|
}
|
|
281
234
|
|
|
282
235
|
# TabCompleteNext and in case we get something unknown
|
|
@@ -284,22 +237,14 @@ function PowerShellCompletionsShared() {
|
|
|
284
237
|
# Like MenuComplete but we don't want to add a space here because
|
|
285
238
|
# the user need to press space anyway to get the completion.
|
|
286
239
|
# Description will not be shown because that's not possible with TabCompleteNext
|
|
287
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${
|
|
240
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${h.value}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
288
241
|
}
|
|
289
242
|
}
|
|
290
243
|
}
|
|
291
244
|
}
|
|
292
245
|
|
|
293
|
-
Register-ArgumentCompleter -CommandName '${
|
|
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 => {
|
|
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 => {
|
|
303
248
|
if (!line.trim()) {
|
|
304
249
|
return "";
|
|
305
250
|
}
|
|
@@ -320,13 +265,5 @@ Register-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${name.va
|
|
|
320
265
|
.replaceAll(/\\$?__\\w/g, bold(magentaBright("$&")))
|
|
321
266
|
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
322
267
|
|
|
323
|
-
}).join("\\n"); `
|
|
324
|
-
})
|
|
325
|
-
];
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
//#endregion
|
|
331
|
-
export { PowerShellCompletionsShared };
|
|
268
|
+
}).join("\\n"); `})]}})}export{p as PowerShellCompletionsShared};
|
|
332
269
|
//# 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":";;;;;;;;;;;;;;;;;AAkCA,SAAgB,8BAAgB;;CAE9B,MAAM,MAAM,eAAe,UAAU,QAAQ,CAAC;CAC9C,MAAM,OAAO,eAAe,UAAU,IAAI,MAAM,CAAC;;EAEjD,IAAM,OAAC;AACJ,UAAA,UAAA,QAAA,WAAA,eAAA,cAAA,YAAA;;EAED,gBAAY,EACV,SAAG;GAAA;GAAY;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA,EAChB;EACD,IAAI,WAAU;AACZ,UAAC;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACD,SAAA;KACE,UAAS;KACT,MAAG;KACH,IAAG,cAAM;AACP,aAAK,IAAA,kCAAA,YAAA,QAAA,CAAA;;;iBAGC,KAAA,MAAA;;;;;;eAMF,KAAA,MAAA;;;;kBAIP,KAAA,MAAA;;;;;;;;;;;QAWH,KAAA,MAAA;;QAEA,KAAS,MAAM;;;;;;;;;;;;+BAYQ,oBAAA,yBAAA;iCACH,oBAAA,2BAAA;;uCAEG,oBAAA,iCAAA;oCACS,oBAAoB,8BAAiB;mCAC9C,oBAAiB,6BAAiC;;;;;;;QAOrE,KAAC,MAAQ;;wBAEb,aAAA;QACI,KAAK,MAAM;;;;;;;;QAQb,KAAA,MAAA;;;;;;YAMA,KAAA,MAAA;;;;;;;;YAQM,KAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2BX,KAAK,MAAI;;;;QAIT,KAAK,MAAE;;;YAGH,KAAE,MAAA;;;;;;;;YAQH,KAAI,MAAQ;;;;;;;;;;;;;;;;;;;YAmBnB,KAAA,MAAA;;;;;;YAMQ,KAAK,MAAM;;;;;;;;;;;;gBAYP,KAAI,MAAO;;;;;;;;;;;YAWhB,KAAA,MAAW;;;;;;;;;;;;;;QAcd,KAAE,MAAS;;;;;;;;;;;;;;;;;;;;;;;;;wBAyBf,KAAA,MAAA;;;4FAGuE,KAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyCpE,CAAC;IAAE,gBAAe,SAAY,EAAE,CAAC;IAAA,gBAAA,gBAAA;KAChC,UAAU;KACV,SAAS;KACT,MAAM;;;;;;;;;;;;;;;;;;;;;;;KAuBP,CAAC;IAAC;;EAEN,CAAC"}
|
|
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"}
|