@shell-shock/plugin-completions 0.2.23 → 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 (133) 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-shared.cjs +303 -0
  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-shared.mjs +303 -0
  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-shared.cjs +319 -0
  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} +81 -181
  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-shared.cjs +281 -0
  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-shared.mjs +281 -0
  89. package/dist/components/zsh-shared.mjs.map +1 -0
  90. package/dist/helpers/complete-command.cjs +2 -7
  91. package/dist/helpers/complete-command.d.cts +2 -2
  92. package/dist/helpers/complete-command.d.cts.map +1 -1
  93. package/dist/helpers/complete-command.d.mts +2 -2
  94. package/dist/helpers/complete-command.d.mts.map +1 -1
  95. package/dist/helpers/complete-command.mjs +2 -7
  96. package/dist/helpers/complete-command.mjs.map +1 -1
  97. package/dist/helpers/index.cjs +1 -1
  98. package/dist/helpers/index.d.cts +2 -2
  99. package/dist/helpers/index.d.mts +2 -2
  100. package/dist/helpers/index.mjs +2 -2
  101. package/dist/index.cjs +245 -59
  102. package/dist/index.d.cts.map +1 -1
  103. package/dist/index.d.mts.map +1 -1
  104. package/dist/index.mjs +246 -60
  105. package/dist/index.mjs.map +1 -1
  106. package/package.json +148 -37
  107. package/dist/components/bash-command.cjs +0 -273
  108. package/dist/components/bash-command.d.cts +0 -10
  109. package/dist/components/bash-command.d.cts.map +0 -1
  110. package/dist/components/bash-command.d.mts +0 -10
  111. package/dist/components/bash-command.d.mts.map +0 -1
  112. package/dist/components/bash-command.mjs +0 -273
  113. package/dist/components/bash-command.mjs.map +0 -1
  114. package/dist/components/fish-command.cjs +0 -403
  115. package/dist/components/fish-command.d.cts +0 -10
  116. package/dist/components/fish-command.d.cts.map +0 -1
  117. package/dist/components/fish-command.d.mts +0 -10
  118. package/dist/components/fish-command.d.mts.map +0 -1
  119. package/dist/components/fish-command.mjs +0 -403
  120. package/dist/components/fish-command.mjs.map +0 -1
  121. package/dist/components/powershell-command.cjs +0 -419
  122. package/dist/components/powershell-command.d.cts +0 -10
  123. package/dist/components/powershell-command.d.cts.map +0 -1
  124. package/dist/components/powershell-command.d.mts +0 -10
  125. package/dist/components/powershell-command.d.mts.map +0 -1
  126. package/dist/components/powershell-command.mjs.map +0 -1
  127. package/dist/components/zsh-command.cjs +0 -384
  128. package/dist/components/zsh-command.d.cts +0 -10
  129. package/dist/components/zsh-command.d.cts.map +0 -1
  130. package/dist/components/zsh-command.d.mts +0 -10
  131. package/dist/components/zsh-command.d.mts.map +0 -1
  132. package/dist/components/zsh-command.mjs +0 -384
  133. package/dist/components/zsh-command.mjs.map +0 -1
@@ -1,384 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_helpers_complete_command = require('../helpers/complete-command.cjs');
3
- const require_helpers_completion_directive_constants = require('../helpers/completion-directive-constants.cjs');
4
- let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
- let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
6
- let _stryke_path = require("@stryke/path");
7
- let _alloy_js_core = require("@alloy-js/core");
8
- let _alloy_js_typescript = require("@alloy-js/typescript");
9
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
10
- let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
11
- let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
12
- let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
13
- let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
14
- let _stryke_string_format = require("@stryke/string-format");
15
-
16
- //#region src/components/zsh-command.tsx
17
- /**
18
- * The Zsh Completions commands' handler wrapper for the Shell Shock project.
19
- */
20
- function ZshCompletionsCommand() {
21
- const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
22
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
23
- get path() {
24
- return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "zsh", "command.ts");
25
- },
26
- imports: {
27
- "node:os": ["os"],
28
- "node:fs/promises": ["readFile", "writeFile"]
29
- },
30
- builtinImports: { "shell-shock:console": [
31
- "colors",
32
- "writeLine",
33
- "success",
34
- "warn",
35
- "stripAnsi"
36
- ] },
37
- get children() {
38
- return [
39
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Zsh completions command." }),
40
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
41
- "export": true,
42
- name: "ZshCompletionsOptions",
43
- get children() {
44
- return [
45
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
46
- heading: "The path to write the completion script to.",
47
- get children() {
48
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `If no extension is provided, the \`.zsh\` extension will be used.` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
49
- get type() {
50
- return _powerlines_deepkit_vendor_type.ReflectionKind.string;
51
- },
52
- get defaultValue() {
53
- return `${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}-completions.zsh`;
54
- }
55
- })];
56
- }
57
- }),
58
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
59
- name: "script",
60
- optional: true,
61
- type: "string | true"
62
- }),
63
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
64
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
65
- heading: "The Zsh configuration file to append the completion script to.",
66
- get children() {
67
- 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 Zsh configuration file include: \\n- \`~/.zshrc\` \\n- \`~/.zprofile\`` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
68
- get type() {
69
- return _powerlines_deepkit_vendor_type.ReflectionKind.string;
70
- },
71
- defaultValue: "~/.zshrc"
72
- })];
73
- }
74
- }),
75
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
76
- name: "config",
77
- optional: true,
78
- type: "string | true"
79
- })
80
- ];
81
- }
82
- }),
83
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
84
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions zsh\\` command." }),
85
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
86
- "export": true,
87
- "default": true,
88
- async: true,
89
- name: "handler",
90
- parameters: [{
91
- name: "options",
92
- type: "ZshCompletionsOptions"
93
- }],
94
- get children() {
95
- return [
96
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
97
- "const": true,
98
- name: "completions",
99
- type: "string",
100
- get initializer() {
101
- return _alloy_js_core.code`#compdef ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}
102
- compdef _${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))} ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}
103
-
104
- # zsh completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} -*- shell-script -*-
105
-
106
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug() {
107
- local file="$BASH_COMP_DEBUG_FILE"
108
- if [[ -n \${file} ]]; then
109
- echo "$*" >> "\${file}"
110
- fi
111
- }
112
-
113
- _${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}() {
114
- local shellCompDirectiveError=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
115
- local shellCompDirectiveNoSpace=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
116
- local shellCompDirectiveNoFileComp=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoFileComp}
117
- local shellCompDirectiveFilterFileExt=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterFileExt}
118
- local shellCompDirectiveFilterDirs=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterDirs}
119
- local shellCompDirectiveKeepOrder=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
120
-
121
- local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
122
- local -a completions
123
-
124
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "\\n========= starting completion logic =========="
125
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
126
-
127
- # The user could have moved the cursor backwards on the command-line.
128
- # We need to trigger completion from the $CURRENT location, so we need
129
- # to truncate the command-line ($words) up to the $CURRENT location.
130
- # (We cannot use $CURSOR as its value does not work when a command is an alias.)
131
- words=( "\${=words[1,CURRENT]}" )
132
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Truncated words[*]: \${words[*]},"
133
-
134
- lastParam=\${words[-1]}
135
- lastChar=\${lastParam[-1]}
136
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
137
- # For zsh, when completing a flag with an = (e.g., ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n=<TAB>)
138
- # completions must be prefixed with the flag
139
- setopt local_options BASH_REMATCH
140
- if [[ "\${lastParam}" =~ '-.*=' ]]; then
141
- # We are dealing with a flag with an =
142
- flagPrefix="-P \${BASH_REMATCH}"
143
- fi
144
-
145
- # Prepare the command to obtain completions, ensuring arguments are quoted for eval
146
- local -a args_to_quote=("\${(@)words[2,-1]}")
147
- if [ "\${lastChar}" = "" ]; then
148
- # If the last parameter is complete (there is a space following it)
149
- # We add an extra empty parameter so we can indicate this to the go completion code.
150
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding extra empty parameter"
151
- args_to_quote+=("")
152
- fi
153
-
154
- # Use Zsh's (q) flag to quote each argument safely for eval
155
- local quoted_args=("\${(@q)args_to_quote}")
156
-
157
- # Join the main command and the quoted arguments into a single string for eval
158
- requestComp="${require_helpers_complete_command.exec} complete -- \${quoted_args[*]}"
159
-
160
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "About to call: eval \${requestComp}"
161
-
162
- # Use eval to handle any environment variables and such
163
- out=$(eval \${requestComp} 2>/dev/null)
164
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "completion output: \${out}"
165
-
166
- # Extract the directive integer following a : from the last line
167
- local lastLine
168
- while IFS='\n' read -r line; do
169
- lastLine=\${line}
170
- done < <(printf "%s\n" "\${out[@]}")
171
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "last line: \${lastLine}"
172
-
173
- if [ "\${lastLine[1]}" = : ]; then
174
- directive=\${lastLine[2,-1]}
175
- # Remove the directive including the : and the newline
176
- local suffix
177
- (( suffix=\${#lastLine}+2))
178
- out=\${out[1,-$suffix]}
179
- else
180
- # There is no directive specified. Leave $out as is.
181
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "No directive found. Setting to default"
182
- directive=0
183
- fi
184
-
185
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "directive: \${directive}"
186
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "completions: \${out}"
187
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "flagPrefix: \${flagPrefix}"
188
-
189
- if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
190
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Completion received error. Ignoring completions."
191
- return
192
- fi
193
-
194
- local activeHelpMarker="%"
195
- local endIndex=\${#activeHelpMarker}
196
- local startIndex=$((\${#activeHelpMarker}+1))
197
- local hasActiveHelp=0
198
- while IFS='\n' read -r comp; do
199
- # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
200
- if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
201
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "ActiveHelp found: $comp"
202
- comp="\${comp[$startIndex,-1]}"
203
- if [ -n "$comp" ]; then
204
- compadd -x "\${comp}"
205
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "ActiveHelp will need delimiter"
206
- hasActiveHelp=1
207
- fi
208
- continue
209
- fi
210
-
211
- if [ -n "$comp" ]; then
212
- # If requested, completions are returned with a description.
213
- # The description is preceded by a TAB character.
214
- # For zsh's _describe, we need to use a : instead of a TAB.
215
- # We first need to escape any : as part of the completion itself.
216
- comp=\${comp//:/\\:}
217
-
218
- local tab="$(printf '\\t')"
219
- comp=\${comp//$tab/:}
220
-
221
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding completion: \${comp}"
222
- completions+=\${comp}
223
- lastComp=$comp
224
- fi
225
- done < <(printf "%s\n" "\${out[@]}")
226
-
227
- # Add a delimiter after the activeHelp statements, but only if:
228
- # - there are completions following the activeHelp statements, or
229
- # - file completion will be performed (so there will be choices after the activeHelp)
230
- if [ $hasActiveHelp -eq 1 ]; then
231
- if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
232
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding activeHelp delimiter"
233
- compadd -x "--"
234
- hasActiveHelp=0
235
- fi
236
- fi
237
-
238
- if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
239
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating nospace."
240
- noSpace="-S ''"
241
- fi
242
-
243
- if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
244
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating keep order."
245
- keepOrder="-V"
246
- fi
247
-
248
- if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
249
- # File extension filtering
250
- local filteringCmd
251
- filteringCmd='_files'
252
- for filter in \${completions[@]}; do
253
- if [ \${filter[1]} != '*' ]; then
254
- # zsh requires a glob pattern to do file filtering
255
- filter="\\*.$filter"
256
- fi
257
- filteringCmd+=" -g $filter"
258
- done
259
- filteringCmd+=" \${flagPrefix}"
260
-
261
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "File filtering command: $filteringCmd"
262
- _arguments '*:filename:'"$filteringCmd"
263
- elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
264
- # File completion for directories only
265
- local subdir
266
- subdir="\${completions[1]}"
267
- if [ -n "$subdir" ]; then
268
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Listing directories in $subdir"
269
- pushd "\${subdir}" >/dev/null 2>&1
270
- else
271
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Listing directories in ."
272
- fi
273
-
274
- local result
275
- _arguments '*:dirname:_files -/'" \${flagPrefix}"
276
- result=$?
277
- if [ -n "$subdir" ]; then
278
- popd >/dev/null 2>&1
279
- fi
280
- return $result
281
- else
282
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Calling _describe"
283
- if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
284
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "_describe found some completions"
285
-
286
- # Return the success of having called _describe
287
- return 0
288
- else
289
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "_describe did not find completions."
290
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Checking if we should do file completion."
291
- if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
292
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "deactivating file completion"
293
-
294
- # Return 0 to indicate completion is finished and prevent zsh from
295
- # trying other completion algorithms (which could cause hanging).
296
- # We use NoFileComp directive to explicitly disable file completion.
297
- return 0
298
- else
299
- # Perform file completion
300
- __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating file completion"
301
-
302
- # We must return the result of this command, so it must be the
303
- # last command, or else we must store its result to return it.
304
- _arguments '*:filename:_files'" \${flagPrefix}"
305
- fi
306
- fi
307
- fi
308
- }
309
-
310
- # don't run the completion function when being sourced or eval-ed
311
- if [ "\${funcstack[1]}" = "_${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}" ]; then
312
- _${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}
313
- fi
314
- \`);`;
315
- }
316
- }),
317
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
318
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
319
- condition: _alloy_js_core.code`options.config`,
320
- get children() {
321
- return [
322
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
323
- "let": true,
324
- name: "configFilePath",
325
- type: "string",
326
- initializer: _alloy_js_core.code`options.config === true ? "~/.zshrc" : options.config`
327
- }),
328
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
329
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
330
- condition: _alloy_js_core.code`configFilePath.startsWith("~")`,
331
- children: _alloy_js_core.code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
332
- }),
333
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
334
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
335
- "let": true,
336
- name: "configFileContent",
337
- type: "string",
338
- initializer: _alloy_js_core.code`"";`
339
- }),
340
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
341
- (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
342
- configFileContent = await readFile(configFilePath, "utf8");
343
- } catch (error) {
344
- if (error.code === "ENOENT") {
345
- // If the file doesn't exist, we can create it later when writing the completion script.
346
- warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
347
- } else {
348
- return { error };
349
- }
350
- }
351
-
352
- await writeFile(configFilePath, \`\${configFileContent}\\n\\n\${stripAnsi(completions)}\`);
353
-
354
- success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh completion script has been generated and appended to \${colors.bold(configFilePath)}. Please restart your terminal or run \`source \${configFilePath}\` to apply the changes.\`); `)
355
- ];
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.script`,
361
- get children() {
362
- return _alloy_js_core.code`const outputPath = options.script === true ? "${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}-completions.zsh" : options.script;
363
- await writeFile(outputPath, stripAnsi(completions));
364
-
365
- success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh completion script has been generated at \${colors.bold(outputPath)}.\`);`;
366
- }
367
- }),
368
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
369
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
370
- condition: _alloy_js_core.code`!options.config && !options.script`,
371
- children: _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
372
- writeLine(completions);
373
- writeLine(" ------------------------------------------------- ");`
374
- })
375
- ];
376
- }
377
- })
378
- ];
379
- }
380
- });
381
- }
382
-
383
- //#endregion
384
- exports.ZshCompletionsCommand = ZshCompletionsCommand;
@@ -1,10 +0,0 @@
1
- import * as _$_alloy_js_core0 from "@alloy-js/core";
2
-
3
- //#region src/components/zsh-command.d.ts
4
- /**
5
- * The Zsh Completions commands' handler wrapper for the Shell Shock project.
6
- */
7
- declare function ZshCompletionsCommand(): _$_alloy_js_core0.Children;
8
- //#endregion
9
- export { ZshCompletionsCommand };
10
- //# sourceMappingURL=zsh-command.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zsh-command.d.cts","names":[],"sources":["../../src/components/zsh-command.tsx"],"mappings":";;;;;;iBA+CgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA"}
@@ -1,10 +0,0 @@
1
- import * as _$_alloy_js_core0 from "@alloy-js/core";
2
-
3
- //#region src/components/zsh-command.d.ts
4
- /**
5
- * The Zsh Completions commands' handler wrapper for the Shell Shock project.
6
- */
7
- declare function ZshCompletionsCommand(): _$_alloy_js_core0.Children;
8
- //#endregion
9
- export { ZshCompletionsCommand };
10
- //# sourceMappingURL=zsh-command.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zsh-command.d.mts","names":[],"sources":["../../src/components/zsh-command.tsx"],"mappings":";;;;;;iBA+CgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA"}