@shell-shock/plugin-completions 0.2.24 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +1 -1
  2. package/dist/components/bash-config-command.cjs +132 -0
  3. package/dist/components/bash-config-command.d.cts +10 -0
  4. package/dist/components/bash-config-command.d.cts.map +1 -0
  5. package/dist/components/bash-config-command.d.mts +10 -0
  6. package/dist/components/bash-config-command.d.mts.map +1 -0
  7. package/dist/components/bash-config-command.mjs +132 -0
  8. package/dist/components/bash-config-command.mjs.map +1 -0
  9. package/dist/components/bash-script-command.cjs +106 -0
  10. package/dist/components/bash-script-command.d.cts +10 -0
  11. package/dist/components/bash-script-command.d.cts.map +1 -0
  12. package/dist/components/bash-script-command.d.mts +10 -0
  13. package/dist/components/bash-script-command.d.mts.map +1 -0
  14. package/dist/components/bash-script-command.mjs +106 -0
  15. package/dist/components/bash-script-command.mjs.map +1 -0
  16. package/dist/components/bash-shared.cjs +172 -0
  17. package/dist/components/bash-shared.d.cts +10 -0
  18. package/dist/components/bash-shared.d.cts.map +1 -0
  19. package/dist/components/bash-shared.d.mts +10 -0
  20. package/dist/components/bash-shared.d.mts.map +1 -0
  21. package/dist/components/bash-shared.mjs +172 -0
  22. package/dist/components/bash-shared.mjs.map +1 -0
  23. package/dist/components/fish-config-command.cjs +132 -0
  24. package/dist/components/fish-config-command.d.cts +10 -0
  25. package/dist/components/fish-config-command.d.cts.map +1 -0
  26. package/dist/components/fish-config-command.d.mts +10 -0
  27. package/dist/components/fish-config-command.d.mts.map +1 -0
  28. package/dist/components/fish-config-command.mjs +132 -0
  29. package/dist/components/fish-config-command.mjs.map +1 -0
  30. package/dist/components/fish-script-command.cjs +106 -0
  31. package/dist/components/fish-script-command.d.cts +10 -0
  32. package/dist/components/fish-script-command.d.cts.map +1 -0
  33. package/dist/components/fish-script-command.d.mts +10 -0
  34. package/dist/components/fish-script-command.d.mts.map +1 -0
  35. package/dist/components/fish-script-command.mjs +106 -0
  36. package/dist/components/fish-script-command.mjs.map +1 -0
  37. package/dist/components/{fish-command.cjs → fish-shared.cjs} +40 -144
  38. package/dist/components/fish-shared.d.cts +10 -0
  39. package/dist/components/fish-shared.d.cts.map +1 -0
  40. package/dist/components/fish-shared.d.mts +10 -0
  41. package/dist/components/fish-shared.d.mts.map +1 -0
  42. package/dist/components/{fish-command.mjs → fish-shared.mjs} +45 -149
  43. package/dist/components/fish-shared.mjs.map +1 -0
  44. package/dist/components/index.cjs +24 -8
  45. package/dist/components/index.d.cts +13 -5
  46. package/dist/components/index.d.mts +13 -5
  47. package/dist/components/index.mjs +13 -5
  48. package/dist/components/powershell-config-command.cjs +128 -0
  49. package/dist/components/powershell-config-command.d.cts +7 -0
  50. package/dist/components/powershell-config-command.d.cts.map +1 -0
  51. package/dist/components/powershell-config-command.d.mts +7 -0
  52. package/dist/components/powershell-config-command.d.mts.map +1 -0
  53. package/dist/components/powershell-config-command.mjs +128 -0
  54. package/dist/components/powershell-config-command.mjs.map +1 -0
  55. package/dist/components/powershell-script-command.cjs +106 -0
  56. package/dist/components/powershell-script-command.d.cts +10 -0
  57. package/dist/components/powershell-script-command.d.cts.map +1 -0
  58. package/dist/components/powershell-script-command.d.mts +10 -0
  59. package/dist/components/powershell-script-command.d.mts.map +1 -0
  60. package/dist/components/powershell-script-command.mjs +106 -0
  61. package/dist/components/powershell-script-command.mjs.map +1 -0
  62. package/dist/components/{powershell-command.cjs → powershell-shared.cjs} +40 -146
  63. package/dist/components/powershell-shared.d.cts +10 -0
  64. package/dist/components/powershell-shared.d.cts.map +1 -0
  65. package/dist/components/powershell-shared.d.mts +10 -0
  66. package/dist/components/powershell-shared.d.mts.map +1 -0
  67. package/dist/components/{powershell-command.mjs → powershell-shared.mjs} +44 -150
  68. package/dist/components/powershell-shared.mjs.map +1 -0
  69. package/dist/components/zsh-config-command.cjs +132 -0
  70. package/dist/components/zsh-config-command.d.cts +10 -0
  71. package/dist/components/zsh-config-command.d.cts.map +1 -0
  72. package/dist/components/zsh-config-command.d.mts +10 -0
  73. package/dist/components/zsh-config-command.d.mts.map +1 -0
  74. package/dist/components/zsh-config-command.mjs +132 -0
  75. package/dist/components/zsh-config-command.mjs.map +1 -0
  76. package/dist/components/zsh-script-command.cjs +111 -0
  77. package/dist/components/zsh-script-command.d.cts +10 -0
  78. package/dist/components/zsh-script-command.d.cts.map +1 -0
  79. package/dist/components/zsh-script-command.d.mts +10 -0
  80. package/dist/components/zsh-script-command.d.mts.map +1 -0
  81. package/dist/components/zsh-script-command.mjs +111 -0
  82. package/dist/components/zsh-script-command.mjs.map +1 -0
  83. package/dist/components/{zsh-command.cjs → zsh-shared.cjs} +41 -147
  84. package/dist/components/zsh-shared.d.cts +10 -0
  85. package/dist/components/zsh-shared.d.cts.map +1 -0
  86. package/dist/components/zsh-shared.d.mts +10 -0
  87. package/dist/components/zsh-shared.d.mts.map +1 -0
  88. package/dist/components/{zsh-command.mjs → zsh-shared.mjs} +45 -151
  89. package/dist/components/zsh-shared.mjs.map +1 -0
  90. package/dist/index.cjs +232 -68
  91. package/dist/index.d.cts.map +1 -1
  92. package/dist/index.d.mts.map +1 -1
  93. package/dist/index.mjs +232 -68
  94. package/dist/index.mjs.map +1 -1
  95. package/package.json +148 -36
  96. package/dist/components/bash-command.cjs +0 -276
  97. package/dist/components/bash-command.d.cts +0 -10
  98. package/dist/components/bash-command.d.cts.map +0 -1
  99. package/dist/components/bash-command.d.mts +0 -10
  100. package/dist/components/bash-command.d.mts.map +0 -1
  101. package/dist/components/bash-command.mjs +0 -276
  102. package/dist/components/bash-command.mjs.map +0 -1
  103. package/dist/components/fish-command.d.cts +0 -10
  104. package/dist/components/fish-command.d.cts.map +0 -1
  105. package/dist/components/fish-command.d.mts +0 -10
  106. package/dist/components/fish-command.d.mts.map +0 -1
  107. package/dist/components/fish-command.mjs.map +0 -1
  108. package/dist/components/powershell-command.d.cts +0 -10
  109. package/dist/components/powershell-command.d.cts.map +0 -1
  110. package/dist/components/powershell-command.d.mts +0 -10
  111. package/dist/components/powershell-command.d.mts.map +0 -1
  112. package/dist/components/powershell-command.mjs.map +0 -1
  113. package/dist/components/zsh-command.d.cts +0 -10
  114. package/dist/components/zsh-command.d.cts.map +0 -1
  115. package/dist/components/zsh-command.d.mts +0 -10
  116. package/dist/components/zsh-command.d.mts.map +0 -1
  117. package/dist/components/zsh-command.mjs.map +0 -1
@@ -1,106 +1,39 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_helpers_complete_command = require('../helpers/complete-command.cjs');
3
3
  const require_helpers_completion_directive_constants = require('../helpers/completion-directive-constants.cjs');
4
+ require('../helpers/index.cjs');
4
5
  let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
6
  let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
6
7
  let _alloy_js_core = require("@alloy-js/core");
7
8
  let _alloy_js_typescript = require("@alloy-js/typescript");
8
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
9
9
  let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
10
10
  let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
11
11
  let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
12
- let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
13
12
  let _stryke_path = require("@stryke/path");
14
13
  let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
15
14
 
16
- //#region src/components/powershell-command.tsx
15
+ //#region src/components/powershell-shared.tsx
17
16
  /**
18
- * The PowerShell Completions commands' handler wrapper for the Shell Shock project.
17
+ * The PowerShell Completions generation for the Shell Shock project.
19
18
  */
20
- function PowerShellCompletionsCommand() {
19
+ function PowerShellCompletionsShared() {
21
20
  const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
22
21
  const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
23
22
  const name = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_camel_case.camelCase)(bin.value));
24
23
  return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
25
24
  get path() {
26
- return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "powershell", "command.ts");
25
+ return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "powershell", "shared.ts");
27
26
  },
28
- imports: {
29
- "node:os": ["os"],
30
- "node:fs/promises": ["readFile", "writeFile"]
31
- },
32
- builtinImports: { "shell-shock:console": [
33
- "colors",
34
- "writeLine",
35
- "success",
36
- "warn",
37
- "stripAnsi"
38
- ] },
27
+ builtinImports: { console: ["colors"] },
39
28
  get children() {
40
29
  return [
41
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the PowerShell completions command." }),
42
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
43
- "export": true,
44
- name: "PowerShellCompletionsOptions",
45
- get children() {
46
- return [
47
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
48
- heading: "The path to write the completion script to.",
49
- get children() {
50
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `If no extension is provided, the \`.ps1\` extension will be used.` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
51
- get type() {
52
- return _powerlines_deepkit_vendor_type.ReflectionKind.string;
53
- },
54
- get defaultValue() {
55
- return `${bin.value}-completions.ps1`;
56
- }
57
- })];
58
- }
59
- }),
60
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
61
- name: "script",
62
- optional: true,
63
- type: "string | true"
64
- }),
65
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
66
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
67
- heading: "The PowerShell configuration file to append the completion script to.",
68
- get children() {
69
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The generated completion script will be appended to the specified configuration file. Possible values for the PowerShell configuration file include: \\n- \`~/.config/powershell/Microsoft.PowerShell_profile.ps1\`` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
70
- get type() {
71
- return _powerlines_deepkit_vendor_type.ReflectionKind.string;
72
- },
73
- defaultValue: "~/.config/powershell/Microsoft.PowerShell_profile.ps1"
74
- })];
75
- }
76
- }),
77
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
78
- name: "config",
79
- optional: true,
80
- type: "string | true"
81
- })
82
- ];
83
- }
84
- }),
85
30
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
86
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions powershell\\` command." }),
87
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
31
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
32
+ "const": true,
88
33
  "export": true,
89
- "default": true,
90
- async: true,
91
- name: "handler",
92
- parameters: [{
93
- name: "options",
94
- type: "PowerShellCompletionsOptions"
95
- }],
96
- get children() {
97
- return [
98
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
99
- "const": true,
100
- name: "completions",
101
- type: "string",
102
- get initializer() {
103
- return _alloy_js_core.code` \`# powershell completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} -*- shell-script -*-
34
+ name: "SHELL_COMPLETIONS",
35
+ get initializer() {
36
+ return _alloy_js_core.code` \`# powershell completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}
104
37
 
105
38
  [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
106
39
  function __${name.value}_debug {
@@ -128,8 +61,6 @@ function PowerShellCompletionsCommand() {
128
61
  __${name.value}_debug "========= starting completion logic =========="
129
62
  __${name.value}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
130
63
 
131
- )}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
132
-
133
64
  # The user could have moved the cursor backwards on the command-line.
134
65
  # We need to trigger completion from the $CursorPosition location, so we need
135
66
  # to truncate the command-line ($Command) up to the $CursorPosition location.
@@ -215,10 +146,6 @@ function PowerShellCompletionsCommand() {
215
146
  return
216
147
  }
217
148
 
218
- ${bin.value}_debug "Received error from custom completion go code"
219
- return
220
- }
221
-
222
149
  $Longest = 0
223
150
  [Array]$Values = $Out | ForEach-Object {
224
151
  # Split the output in name and description
@@ -301,7 +228,7 @@ function PowerShellCompletionsCommand() {
301
228
  # CompletionResult Arguments:
302
229
  # 1) CompletionText text to be used as the auto completion result
303
230
  # 2) ListItemText text to be displayed in the suggestion list
304
- # 3) ResultType type of completion result
231
+ # 3) ResultType type of completion result
305
232
  # 4) ToolTip text for the tooltip with details about the object
306
233
 
307
234
  switch ($Mode) {
@@ -353,68 +280,35 @@ function PowerShellCompletionsCommand() {
353
280
 
354
281
  Register-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${name.value}CompleterBlock
355
282
  \`; `;
356
- }
357
- }),
358
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
359
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
360
- condition: _alloy_js_core.code`options.config`,
361
- get children() {
362
- return [
363
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
364
- "let": true,
365
- name: "configFilePath",
366
- type: "string",
367
- initializer: _alloy_js_core.code`options.config === true ? "~/.config/powershell/Microsoft.PowerShell_profile.ps1" : options.config`
368
- }),
369
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
370
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
371
- condition: _alloy_js_core.code`configFilePath.startsWith("~")`,
372
- children: _alloy_js_core.code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
373
- }),
374
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
375
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
376
- "let": true,
377
- name: "configFileContent",
378
- type: "string",
379
- initializer: _alloy_js_core.code`"";`
380
- }),
381
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
382
- (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
383
- configFileContent = await readFile(configFilePath, "utf8");
384
- } catch (error) {
385
- if (Error.isError(error) && error.code === "ENOENT") {
386
- // If the file doesn't exist, we can create it later when writing the completion script.
387
- warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
388
- } else {
389
- return { error };
390
- }
283
+ }
284
+ }),
285
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
286
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
287
+ "export": true,
288
+ "const": true,
289
+ name: "SHELL_COMPLETIONS_DISPLAY",
290
+ initializer: _alloy_js_core.code` SHELL_COMPLETIONS.split("\\n").map(line => {
291
+ if (!line.trim()) {
292
+ return "";
293
+ }
294
+ if (line.trim().startsWith("#")) {
295
+ return \`\${colors.dim(line)}\`;
391
296
  }
392
297
 
393
- await writeFile(configFilePath, \`\${configFileContent}\\n\\n\${stripAnsi(completions)}\`);
394
-
395
- success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell completion script has been generated and appended to \${colors.bold(configFilePath)}. Please restart your terminal or run \`source \${configFilePath}\` to apply the changes.\`); `)
396
- ];
397
- }
398
- }),
399
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
400
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
401
- condition: _alloy_js_core.code`options.script`,
402
- get children() {
403
- return _alloy_js_core.code`const outputPath = options.script === true ? "${bin.value}-completions.powershell" : options.script;
404
- await writeFile(outputPath, stripAnsi(completions));
405
-
406
- success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell completion script has been generated at \${colors.bold(outputPath)}.\`);`;
407
- }
408
- }),
409
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
410
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
411
- condition: _alloy_js_core.code`!options.config && !options.script`,
412
- children: _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
413
- writeLine(completions);
414
- writeLine(" ------------------------------------------------- ");`
415
- })
416
- ];
417
- }
298
+ return colors.white(line).replaceAll(/(?<=\\\$(\\{|\\()).*(?=(\\}\\)))/g, colors.green("$&"))
299
+ .replaceAll(/\\".*\\"/g, colors.cyan("$&"))
300
+ .replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|::new|::OutputEncoding|::UTF8)/g, colors.bold(colors.gray("$&")))
301
+ .replaceAll(/(switch|complete)\\s+/g, colors.green("$&"))
302
+ .replaceAll(/(?<=(switch|complete)\\s+)\\w/g, colors.bold(colors.greenBright("$&")))
303
+ .replaceAll(/(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\w+)\\s+/g, colors.red("$&"))
304
+ .replaceAll(/(?<=(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\w+)\\s+)\\w/g, colors.bold(colors.redBright("$&")))
305
+ .replaceAll(/while\\s+/g, colors.cyan("$&"))
306
+ .replaceAll(/(?<=while\\s+)\\w/g, colors.bold(colors.cyanBright("$&")))
307
+ .replaceAll(/(if|fi|else|elif|then|done)\\s+/g, colors.green("$&"))
308
+ .replaceAll(/\\$?__\\w/g, colors.bold(colors.magentaBright("$&")))
309
+ .replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, colors.bold(colors.magenta("$&")));
310
+
311
+ }).join("\\n"); `
418
312
  })
419
313
  ];
420
314
  }
@@ -422,4 +316,4 @@ Register-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${name.va
422
316
  }
423
317
 
424
318
  //#endregion
425
- exports.PowerShellCompletionsCommand = PowerShellCompletionsCommand;
319
+ exports.PowerShellCompletionsShared = PowerShellCompletionsShared;
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/powershell-shared.d.ts
4
+ /**
5
+ * The PowerShell Completions generation for the Shell Shock project.
6
+ */
7
+ declare function PowerShellCompletionsShared(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { PowerShellCompletionsShared };
10
+ //# sourceMappingURL=powershell-shared.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-shared.d.cts","names":[],"sources":["../../src/components/powershell-shared.tsx"],"mappings":";;;;;;iBAiCgB,2BAAA,CAAA,GAA2B,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/powershell-shared.d.ts
4
+ /**
5
+ * The PowerShell Completions generation for the Shell Shock project.
6
+ */
7
+ declare function PowerShellCompletionsShared(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { PowerShellCompletionsShared };
10
+ //# sourceMappingURL=powershell-shared.d.mts.map
@@ -0,0 +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,105 +1,38 @@
1
1
  import { EXEC_COMMAND } from "../helpers/complete-command.mjs";
2
2
  import { CompletionDirective } from "../helpers/completion-directive-constants.mjs";
3
- import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
3
+ import "../helpers/index.mjs";
4
+ import { createComponent } from "@alloy-js/core/jsx-runtime";
4
5
  import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
5
6
  import { code, computed } from "@alloy-js/core";
6
- import { FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
7
- import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
7
+ import { VarDeclaration } from "@alloy-js/typescript";
8
8
  import { Spacing } from "@powerlines/plugin-alloy/core";
9
9
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
10
- import { InterfaceMember, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
11
- import { TSDoc, TSDocDefaultValue, TSDocRemarks } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
10
+ import { TypescriptFile } from "@powerlines/plugin-alloy/typescript";
12
11
  import { joinPaths } from "@stryke/path";
13
12
  import { camelCase } from "@stryke/string-format/camel-case";
14
13
 
15
- //#region src/components/powershell-command.tsx
14
+ //#region src/components/powershell-shared.tsx
16
15
  /**
17
- * The PowerShell Completions commands' handler wrapper for the Shell Shock project.
16
+ * The PowerShell Completions generation for the Shell Shock project.
18
17
  */
19
- function PowerShellCompletionsCommand() {
18
+ function PowerShellCompletionsShared() {
20
19
  const context = usePowerlines();
21
20
  const bin = computed(() => getAppBin(context));
22
21
  const name = computed(() => camelCase(bin.value));
23
22
  return createComponent(TypescriptFile, {
24
23
  get path() {
25
- return joinPaths(context.entryPath, "completions", "powershell", "command.ts");
24
+ return joinPaths(context.entryPath, "completions", "powershell", "shared.ts");
26
25
  },
27
- imports: {
28
- "node:os": ["os"],
29
- "node:fs/promises": ["readFile", "writeFile"]
30
- },
31
- builtinImports: { "shell-shock:console": [
32
- "colors",
33
- "writeLine",
34
- "success",
35
- "warn",
36
- "stripAnsi"
37
- ] },
26
+ builtinImports: { console: ["colors"] },
38
27
  get children() {
39
28
  return [
40
- createComponent(TSDoc, { heading: "Options for the PowerShell completions command." }),
41
- createComponent(InterfaceDeclaration, {
42
- "export": true,
43
- name: "PowerShellCompletionsOptions",
44
- get children() {
45
- return [
46
- createComponent(TSDoc, {
47
- heading: "The path to write the completion script to.",
48
- get children() {
49
- return [createComponent(TSDocRemarks, { children: `If no extension is provided, the \`.ps1\` extension will be used.` }), createComponent(TSDocDefaultValue, {
50
- get type() {
51
- return ReflectionKind.string;
52
- },
53
- get defaultValue() {
54
- return `${bin.value}-completions.ps1`;
55
- }
56
- })];
57
- }
58
- }),
59
- createComponent(InterfaceMember, {
60
- name: "script",
61
- optional: true,
62
- type: "string | true"
63
- }),
64
- createComponent(Spacing, {}),
65
- createComponent(TSDoc, {
66
- heading: "The PowerShell configuration file to append the completion script to.",
67
- get children() {
68
- return [createComponent(TSDocRemarks, { children: `The generated completion script will be appended to the specified configuration file. Possible values for the PowerShell configuration file include: \\n- \`~/.config/powershell/Microsoft.PowerShell_profile.ps1\`` }), createComponent(TSDocDefaultValue, {
69
- get type() {
70
- return ReflectionKind.string;
71
- },
72
- defaultValue: "~/.config/powershell/Microsoft.PowerShell_profile.ps1"
73
- })];
74
- }
75
- }),
76
- createComponent(InterfaceMember, {
77
- name: "config",
78
- optional: true,
79
- type: "string | true"
80
- })
81
- ];
82
- }
83
- }),
84
29
  createComponent(Spacing, {}),
85
- createComponent(TSDoc, { heading: "Handler logic for the \\`completions powershell\\` command." }),
86
- createComponent(FunctionDeclaration, {
30
+ createComponent(VarDeclaration, {
31
+ "const": true,
87
32
  "export": true,
88
- "default": true,
89
- async: true,
90
- name: "handler",
91
- parameters: [{
92
- name: "options",
93
- type: "PowerShellCompletionsOptions"
94
- }],
95
- get children() {
96
- return [
97
- createComponent(VarDeclaration, {
98
- "const": true,
99
- name: "completions",
100
- type: "string",
101
- get initializer() {
102
- return code` \`# powershell completion for ${getAppTitle(context)} -*- shell-script -*-
33
+ name: "SHELL_COMPLETIONS",
34
+ get initializer() {
35
+ return code` \`# powershell completion for ${getAppTitle(context)}
103
36
 
104
37
  [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
105
38
  function __${name.value}_debug {
@@ -127,8 +60,6 @@ function PowerShellCompletionsCommand() {
127
60
  __${name.value}_debug "========= starting completion logic =========="
128
61
  __${name.value}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
129
62
 
130
- )}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
131
-
132
63
  # The user could have moved the cursor backwards on the command-line.
133
64
  # We need to trigger completion from the $CursorPosition location, so we need
134
65
  # to truncate the command-line ($Command) up to the $CursorPosition location.
@@ -214,10 +145,6 @@ function PowerShellCompletionsCommand() {
214
145
  return
215
146
  }
216
147
 
217
- ${bin.value}_debug "Received error from custom completion go code"
218
- return
219
- }
220
-
221
148
  $Longest = 0
222
149
  [Array]$Values = $Out | ForEach-Object {
223
150
  # Split the output in name and description
@@ -300,7 +227,7 @@ function PowerShellCompletionsCommand() {
300
227
  # CompletionResult Arguments:
301
228
  # 1) CompletionText text to be used as the auto completion result
302
229
  # 2) ListItemText text to be displayed in the suggestion list
303
- # 3) ResultType type of completion result
230
+ # 3) ResultType type of completion result
304
231
  # 4) ToolTip text for the tooltip with details about the object
305
232
 
306
233
  switch ($Mode) {
@@ -352,68 +279,35 @@ function PowerShellCompletionsCommand() {
352
279
 
353
280
  Register-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${name.value}CompleterBlock
354
281
  \`; `;
355
- }
356
- }),
357
- createComponent(Spacing, {}),
358
- createComponent(IfStatement, {
359
- condition: code`options.config`,
360
- get children() {
361
- return [
362
- createComponent(VarDeclaration, {
363
- "let": true,
364
- name: "configFilePath",
365
- type: "string",
366
- initializer: code`options.config === true ? "~/.config/powershell/Microsoft.PowerShell_profile.ps1" : options.config`
367
- }),
368
- createComponent(Spacing, {}),
369
- createComponent(IfStatement, {
370
- condition: code`configFilePath.startsWith("~")`,
371
- children: code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
372
- }),
373
- createComponent(Spacing, {}),
374
- createComponent(VarDeclaration, {
375
- "let": true,
376
- name: "configFileContent",
377
- type: "string",
378
- initializer: code`"";`
379
- }),
380
- createComponent(Spacing, {}),
381
- memo(() => code`try {
382
- configFileContent = await readFile(configFilePath, "utf8");
383
- } catch (error) {
384
- if (Error.isError(error) && error.code === "ENOENT") {
385
- // If the file doesn't exist, we can create it later when writing the completion script.
386
- warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
387
- } else {
388
- return { error };
389
- }
282
+ }
283
+ }),
284
+ createComponent(Spacing, {}),
285
+ createComponent(VarDeclaration, {
286
+ "export": true,
287
+ "const": true,
288
+ name: "SHELL_COMPLETIONS_DISPLAY",
289
+ initializer: code` SHELL_COMPLETIONS.split("\\n").map(line => {
290
+ if (!line.trim()) {
291
+ return "";
292
+ }
293
+ if (line.trim().startsWith("#")) {
294
+ return \`\${colors.dim(line)}\`;
390
295
  }
391
296
 
392
- await writeFile(configFilePath, \`\${configFileContent}\\n\\n\${stripAnsi(completions)}\`);
393
-
394
- success(\`${getAppTitle(context)} PowerShell completion script has been generated and appended to \${colors.bold(configFilePath)}. Please restart your terminal or run \`source \${configFilePath}\` to apply the changes.\`); `)
395
- ];
396
- }
397
- }),
398
- createComponent(Spacing, {}),
399
- createComponent(IfStatement, {
400
- condition: code`options.script`,
401
- get children() {
402
- return code`const outputPath = options.script === true ? "${bin.value}-completions.powershell" : options.script;
403
- await writeFile(outputPath, stripAnsi(completions));
404
-
405
- success(\`${getAppTitle(context)} PowerShell completion script has been generated at \${colors.bold(outputPath)}.\`);`;
406
- }
407
- }),
408
- createComponent(Spacing, {}),
409
- createComponent(IfStatement, {
410
- condition: code`!options.config && !options.script`,
411
- children: code`writeLine(" ------------------------------------------------- ");
412
- writeLine(completions);
413
- writeLine(" ------------------------------------------------- ");`
414
- })
415
- ];
416
- }
297
+ return colors.white(line).replaceAll(/(?<=\\\$(\\{|\\()).*(?=(\\}\\)))/g, colors.green("$&"))
298
+ .replaceAll(/\\".*\\"/g, colors.cyan("$&"))
299
+ .replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|::new|::OutputEncoding|::UTF8)/g, colors.bold(colors.gray("$&")))
300
+ .replaceAll(/(switch|complete)\\s+/g, colors.green("$&"))
301
+ .replaceAll(/(?<=(switch|complete)\\s+)\\w/g, colors.bold(colors.greenBright("$&")))
302
+ .replaceAll(/(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\w+)\\s+/g, colors.red("$&"))
303
+ .replaceAll(/(?<=(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\w+)\\s+)\\w/g, colors.bold(colors.redBright("$&")))
304
+ .replaceAll(/while\\s+/g, colors.cyan("$&"))
305
+ .replaceAll(/(?<=while\\s+)\\w/g, colors.bold(colors.cyanBright("$&")))
306
+ .replaceAll(/(if|fi|else|elif|then|done)\\s+/g, colors.green("$&"))
307
+ .replaceAll(/\\$?__\\w/g, colors.bold(colors.magentaBright("$&")))
308
+ .replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, colors.bold(colors.magenta("$&")));
309
+
310
+ }).join("\\n"); `
417
311
  })
418
312
  ];
419
313
  }
@@ -421,5 +315,5 @@ Register-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${name.va
421
315
  }
422
316
 
423
317
  //#endregion
424
- export { PowerShellCompletionsCommand };
425
- //# sourceMappingURL=powershell-command.mjs.map
318
+ export { PowerShellCompletionsShared };
319
+ //# sourceMappingURL=powershell-shared.mjs.map
@@ -0,0 +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: [\"colors\"]\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 \\`\\${colors.dim(line)}\\`;\n }\n\n return colors.white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, colors.green(\"$&\"))\n .replaceAll(/\\\\\".*\\\\\"/g, colors.cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|::new|::OutputEncoding|::UTF8)/g, colors.bold(colors.gray(\"$&\")))\n .replaceAll(/(switch|complete)\\\\s+/g, colors.green(\"$&\"))\n .replaceAll(/(?<=(switch|complete)\\\\s+)\\\\w/g, colors.bold(colors.greenBright(\"$&\")))\n .replaceAll(/(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\\\w+)\\\\s+/g, colors.red(\"$&\"))\n .replaceAll(/(?<=(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\\\w+)\\\\s+)\\\\w/g, colors.bold(colors.redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, colors.cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, colors.bold(colors.cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, colors.green(\"$&\"))\n .replaceAll(/\\\\$?__\\\\w/g, colors.bold(colors.magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, colors.bold(colors.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,CAAA,SAAY,EAChB;EACD,IAAI,WAAU;AACZ,UAAC;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACD,SAAA;KACE,UAAU;KACV,MAAA;KACD,IAAA,cAAS;AACT,aAAA,IAAA,kCAAA,YAAA,QAAA,CAAA;;;iBAGO,KAAA,MAAA;;;;;;eAMA,KAAM,MAAM;;;;kBAIX,KAAK,MAAM;;;;;;;;;;;QAWpB,KAAO,MAAC;QACT,KAAQ,MAAG;QACX,KAAQ,MAAI;;;;;;;;;;QAUX,KAAK,MAAQ;;+BAES,oBAAc,yBAAc;iCACpD,oBAAA,2BAAA;oCACgC,oBAAkB,8BAAA;;oCAEvB,oBAAoB,8BAAwB;mCAC1C,oBAAoB,6BAA0B;;;;;;;QAO1E,KAAA,MAAA;;wBAED,aAAA;QACC,KAAA,MAAA;;;;;;;;QAQA,KAAA,MAAc;;;;;;YAMV,KAAO,MAAK;;;;;;;;;;;;;;;;;;;;;QAqBb,KAAE,MAAA;;;;;;;;;;;;;;QAcF,KAAC,MAAU;;;;QAIf,KAAO,MAAA;;;YAGD,KAAA,MAAa;;;;;;;;YAQX,KAAK,MAAM;;;;;;;;;;;;;;;;;;;YAmBb,KAAO,MAAC;;;;;;YAMd,KAAA,MAAA;;;;;;;;;;;;gBAYO,KAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkDW,KAAM,MAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;wFA2Bb,KAAA,MAAA;;;;;;;;;;;;;;2CAcO,IAAA,MAAA,oBAAA,KAAA,MAAA;;;KAGpB,CAAC;IAAE,gBAAY,SAAY,EAAK,CAAC;IAAE,gBAAkB,gBAAY;KAChE,UAAS;KACT,SAAS;KACT,MAAM;KACN,aAAI,IAAA;;;;;;;;;;;;;;;;;;;;;;KAsBL,CAAC;IAAA;;EAEL,CAAC"}