@shell-shock/plugin-completions 0.4.16 → 0.4.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/bash-config-command.cjs +116 -6
- package/dist/components/bash-config-command.d.cts +1 -3
- package/dist/components/bash-config-command.d.cts.map +1 -1
- package/dist/components/bash-config-command.d.mts +1 -3
- package/dist/components/bash-config-command.d.mts.map +1 -1
- package/dist/components/bash-config-command.mjs +115 -6
- package/dist/components/bash-config-command.mjs.map +1 -1
- package/dist/components/bash-script-command.cjs +101 -5
- package/dist/components/bash-script-command.d.cts +1 -3
- package/dist/components/bash-script-command.d.cts.map +1 -1
- package/dist/components/bash-script-command.d.mts +1 -3
- package/dist/components/bash-script-command.d.mts.map +1 -1
- package/dist/components/bash-script-command.mjs +100 -5
- package/dist/components/bash-script-command.mjs.map +1 -1
- package/dist/components/bash-shared.cjs +77 -13
- package/dist/components/bash-shared.d.cts +1 -3
- package/dist/components/bash-shared.d.cts.map +1 -1
- package/dist/components/bash-shared.d.mts +1 -3
- package/dist/components/bash-shared.d.mts.map +1 -1
- package/dist/components/bash-shared.mjs +76 -13
- package/dist/components/bash-shared.mjs.map +1 -1
- package/dist/components/fish-config-command.cjs +116 -6
- package/dist/components/fish-config-command.d.cts +1 -3
- package/dist/components/fish-config-command.d.cts.map +1 -1
- package/dist/components/fish-config-command.d.mts +1 -3
- package/dist/components/fish-config-command.d.mts.map +1 -1
- package/dist/components/fish-config-command.mjs +115 -6
- package/dist/components/fish-config-command.mjs.map +1 -1
- package/dist/components/fish-script-command.cjs +100 -4
- package/dist/components/fish-script-command.d.cts +1 -3
- package/dist/components/fish-script-command.d.cts.map +1 -1
- package/dist/components/fish-script-command.d.mts +1 -3
- package/dist/components/fish-script-command.d.mts.map +1 -1
- package/dist/components/fish-script-command.mjs +99 -4
- package/dist/components/fish-script-command.mjs.map +1 -1
- package/dist/components/fish-shared.cjs +141 -77
- package/dist/components/fish-shared.d.cts +1 -3
- package/dist/components/fish-shared.d.cts.map +1 -1
- package/dist/components/fish-shared.d.mts +1 -3
- package/dist/components/fish-shared.d.mts.map +1 -1
- package/dist/components/fish-shared.mjs +140 -77
- package/dist/components/fish-shared.mjs.map +1 -1
- package/dist/components/index.cjs +26 -1
- package/dist/components/index.mjs +14 -1
- package/dist/components/powershell-config-command.cjs +112 -6
- package/dist/components/powershell-config-command.d.cts +1 -3
- package/dist/components/powershell-config-command.d.cts.map +1 -1
- package/dist/components/powershell-config-command.d.mts +1 -3
- package/dist/components/powershell-config-command.d.mts.map +1 -1
- package/dist/components/powershell-config-command.mjs +111 -6
- package/dist/components/powershell-config-command.mjs.map +1 -1
- package/dist/components/powershell-script-command.cjs +100 -4
- package/dist/components/powershell-script-command.d.cts +1 -3
- package/dist/components/powershell-script-command.d.cts.map +1 -1
- package/dist/components/powershell-script-command.d.mts +1 -3
- package/dist/components/powershell-script-command.d.mts.map +1 -1
- package/dist/components/powershell-script-command.mjs +99 -4
- package/dist/components/powershell-script-command.mjs.map +1 -1
- package/dist/components/powershell-shared.cjs +101 -37
- package/dist/components/powershell-shared.d.cts +1 -3
- package/dist/components/powershell-shared.d.cts.map +1 -1
- package/dist/components/powershell-shared.d.mts +1 -3
- package/dist/components/powershell-shared.d.mts.map +1 -1
- package/dist/components/powershell-shared.mjs +100 -37
- package/dist/components/powershell-shared.mjs.map +1 -1
- package/dist/components/zsh-config-command.cjs +116 -6
- package/dist/components/zsh-config-command.d.cts +1 -3
- package/dist/components/zsh-config-command.d.cts.map +1 -1
- package/dist/components/zsh-config-command.d.mts +1 -3
- package/dist/components/zsh-config-command.d.mts.map +1 -1
- package/dist/components/zsh-config-command.mjs +115 -6
- package/dist/components/zsh-config-command.mjs.map +1 -1
- package/dist/components/zsh-script-command.cjs +104 -6
- package/dist/components/zsh-script-command.d.cts +1 -3
- package/dist/components/zsh-script-command.d.cts.map +1 -1
- package/dist/components/zsh-script-command.d.mts +1 -3
- package/dist/components/zsh-script-command.d.mts.map +1 -1
- package/dist/components/zsh-script-command.mjs +103 -6
- package/dist/components/zsh-script-command.mjs.map +1 -1
- package/dist/components/zsh-shared.cjs +106 -42
- package/dist/components/zsh-shared.d.cts +1 -3
- package/dist/components/zsh-shared.d.cts.map +1 -1
- package/dist/components/zsh-shared.d.mts +1 -3
- package/dist/components/zsh-shared.d.mts.map +1 -1
- package/dist/components/zsh-shared.mjs +105 -42
- package/dist/components/zsh-shared.mjs.map +1 -1
- package/dist/helpers/complete-command.cjs +10 -1
- package/dist/helpers/complete-command.d.mts.map +1 -1
- package/dist/helpers/complete-command.mjs +8 -1
- package/dist/helpers/complete-command.mjs.map +1 -1
- package/dist/helpers/completion-directive-constants.cjs +16 -1
- package/dist/helpers/completion-directive-constants.d.mts.map +1 -1
- package/dist/helpers/completion-directive-constants.mjs +14 -1
- package/dist/helpers/completion-directive-constants.mjs.map +1 -1
- package/dist/helpers/index.cjs +6 -1
- package/dist/helpers/index.mjs +4 -1
- package/dist/index.cjs +290 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +288 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +4 -1
- package/dist/types/index.mjs +3 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/shell-type.cjs +12 -1
- package/dist/types/shell-type.d.cts.map +1 -1
- package/dist/types/shell-type.d.mts.map +1 -1
- package/dist/types/shell-type.mjs +10 -1
- package/dist/types/shell-type.mjs.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zsh-script-command.mjs","names":[],"sources":[
|
|
1
|
+
{"version":3,"file":"zsh-script-command.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1,35 +1,83 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_helpers_complete_command = require('../helpers/complete-command.cjs');
|
|
3
|
+
const require_helpers_completion_directive_constants = require('../helpers/completion-directive-constants.cjs');
|
|
4
|
+
require('../helpers/index.cjs');
|
|
5
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
|
+
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
7
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
8
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
9
|
+
let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
|
|
10
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
11
|
+
let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
|
|
12
|
+
let _stryke_path = require("@stryke/path");
|
|
13
|
+
let _stryke_string_format_snake_case = require("@stryke/string-format/snake-case");
|
|
14
|
+
|
|
15
|
+
//#region src/components/zsh-shared.tsx
|
|
16
|
+
/**
|
|
17
|
+
* The Zsh Completions generation for the Shell Shock project.
|
|
18
|
+
*/
|
|
19
|
+
function ZshCompletionsShared() {
|
|
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_snake_case.snakeCase)(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", "zsh", "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` \`__${name.value}_debug() {
|
|
2
50
|
local file="$BASH_COMP_DEBUG_FILE"
|
|
3
51
|
if [[ -n \\\${file} ]]; then
|
|
4
52
|
echo "$*" >> "\\\${file}"
|
|
5
53
|
fi
|
|
6
54
|
}
|
|
7
55
|
|
|
8
|
-
_${
|
|
9
|
-
local shellCompDirectiveError=${
|
|
10
|
-
local shellCompDirectiveNoSpace=${
|
|
11
|
-
local shellCompDirectiveNoFileComp=${
|
|
12
|
-
local shellCompDirectiveFilterFileExt=${
|
|
13
|
-
local shellCompDirectiveFilterDirs=${
|
|
14
|
-
local shellCompDirectiveKeepOrder=${
|
|
56
|
+
_${name.value}() {
|
|
57
|
+
local shellCompDirectiveError=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
|
|
58
|
+
local shellCompDirectiveNoSpace=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
|
|
59
|
+
local shellCompDirectiveNoFileComp=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoFileComp}
|
|
60
|
+
local shellCompDirectiveFilterFileExt=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterFileExt}
|
|
61
|
+
local shellCompDirectiveFilterDirs=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterDirs}
|
|
62
|
+
local shellCompDirectiveKeepOrder=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
|
|
15
63
|
|
|
16
64
|
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
|
17
65
|
local -a completions
|
|
18
66
|
|
|
19
|
-
__${
|
|
20
|
-
__${
|
|
67
|
+
__${name.value}_debug "\\n========= starting completion logic =========="
|
|
68
|
+
__${name.value}_debug "CURRENT: \\\${CURRENT}, words[*]: \\\${words[*]}"
|
|
21
69
|
|
|
22
70
|
# The user could have moved the cursor backwards on the command-line.
|
|
23
71
|
# We need to trigger completion from the $CURRENT location, so we need
|
|
24
72
|
# to truncate the command-line ($words) up to the $CURRENT location.
|
|
25
73
|
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
|
|
26
74
|
words=( "\\\${=words[1,CURRENT]}" )
|
|
27
|
-
__${
|
|
75
|
+
__${name.value}_debug "Truncated words[*]: \\\${words[*]},"
|
|
28
76
|
|
|
29
77
|
lastParam=\\\${words[-1]}
|
|
30
78
|
lastChar=\\\${lastParam[-1]}
|
|
31
|
-
__${
|
|
32
|
-
# For zsh, when completing a flag with an = (e.g., ${
|
|
79
|
+
__${name.value}_debug "lastParam: \\\${lastParam}, lastChar: \\\${lastChar}"
|
|
80
|
+
# For zsh, when completing a flag with an = (e.g., ${bin.value} -n=<TAB>)
|
|
33
81
|
# completions must be prefixed with the flag
|
|
34
82
|
setopt local_options BASH_REMATCH
|
|
35
83
|
if [[ "\\\${lastParam}" =~ '-.*=' ]]; then
|
|
@@ -42,7 +90,7 @@ _${p.value}() {
|
|
|
42
90
|
if [ "\\\${lastChar}" = "" ]; then
|
|
43
91
|
# If the last parameter is complete (there is a space following it)
|
|
44
92
|
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
45
|
-
__${
|
|
93
|
+
__${name.value}_debug "Adding extra empty parameter"
|
|
46
94
|
args_to_quote+=("")
|
|
47
95
|
fi
|
|
48
96
|
|
|
@@ -50,20 +98,20 @@ _${p.value}() {
|
|
|
50
98
|
local quoted_args=("\\\${(@q)args_to_quote}")
|
|
51
99
|
|
|
52
100
|
# Join the main command and the quoted arguments into a single string for eval
|
|
53
|
-
requestComp="${
|
|
101
|
+
requestComp="${require_helpers_complete_command.EXEC_COMMAND} complete -- \\\${quoted_args[*]}"
|
|
54
102
|
|
|
55
|
-
__${
|
|
103
|
+
__${name.value}_debug "About to call: eval \\\${requestComp}"
|
|
56
104
|
|
|
57
105
|
# Use eval to handle any environment variables and such
|
|
58
106
|
out=$(eval \\\${requestComp} 2>/dev/null)
|
|
59
|
-
__${
|
|
107
|
+
__${name.value}_debug "completion output: \\\${out}"
|
|
60
108
|
|
|
61
109
|
# Extract the directive integer following a : from the last line
|
|
62
110
|
local lastLine
|
|
63
111
|
while IFS='\n' read -r line; do
|
|
64
112
|
lastLine=\\\${line}
|
|
65
113
|
done < <(printf "%s\n" "\\\${out[@]}")
|
|
66
|
-
__${
|
|
114
|
+
__${name.value}_debug "last line: \\\${lastLine}"
|
|
67
115
|
|
|
68
116
|
if [ "\\\${lastLine[1]}" = : ]; then
|
|
69
117
|
directive=\\\${lastLine[2,-1]}
|
|
@@ -73,16 +121,16 @@ _${p.value}() {
|
|
|
73
121
|
out=\\\${out[1,-$suffix]}
|
|
74
122
|
else
|
|
75
123
|
# There is no directive specified. Leave $out as is.
|
|
76
|
-
__${
|
|
124
|
+
__${name.value}_debug "No directive found. Setting to default"
|
|
77
125
|
directive=0
|
|
78
126
|
fi
|
|
79
127
|
|
|
80
|
-
__${
|
|
81
|
-
__${
|
|
82
|
-
__${
|
|
128
|
+
__${name.value}_debug "directive: \\\${directive}"
|
|
129
|
+
__${name.value}_debug "completions: \\\${out}"
|
|
130
|
+
__${name.value}_debug "flagPrefix: \\\${flagPrefix}"
|
|
83
131
|
|
|
84
132
|
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
|
85
|
-
__${
|
|
133
|
+
__${name.value}_debug "Completion received error. Ignoring completions."
|
|
86
134
|
return
|
|
87
135
|
fi
|
|
88
136
|
|
|
@@ -93,11 +141,11 @@ _${p.value}() {
|
|
|
93
141
|
while IFS='\n' read -r comp; do
|
|
94
142
|
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
95
143
|
if [ "\\\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
96
|
-
__${
|
|
144
|
+
__${name.value}_debug "ActiveHelp found: $comp"
|
|
97
145
|
comp="\\\${comp[$startIndex,-1]}"
|
|
98
146
|
if [ -n "$comp" ]; then
|
|
99
147
|
compadd -x "\\\${comp}"
|
|
100
|
-
__${
|
|
148
|
+
__${name.value}_debug "ActiveHelp will need delimiter"
|
|
101
149
|
hasActiveHelp=1
|
|
102
150
|
fi
|
|
103
151
|
continue
|
|
@@ -113,7 +161,7 @@ _${p.value}() {
|
|
|
113
161
|
local tab="$(printf '\\t')"
|
|
114
162
|
comp=\\\${comp//$tab/:}
|
|
115
163
|
|
|
116
|
-
__${
|
|
164
|
+
__${name.value}_debug "Adding completion: \\\${comp}"
|
|
117
165
|
completions+=\\\${comp}
|
|
118
166
|
lastComp=$comp
|
|
119
167
|
fi
|
|
@@ -124,19 +172,19 @@ _${p.value}() {
|
|
|
124
172
|
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
125
173
|
if [ $hasActiveHelp -eq 1 ]; then
|
|
126
174
|
if [ \\\${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
127
|
-
__${
|
|
175
|
+
__${name.value}_debug "Adding activeHelp delimiter"
|
|
128
176
|
compadd -x "--"
|
|
129
177
|
hasActiveHelp=0
|
|
130
178
|
fi
|
|
131
179
|
fi
|
|
132
180
|
|
|
133
181
|
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
|
134
|
-
__${
|
|
182
|
+
__${name.value}_debug "Activating nospace."
|
|
135
183
|
noSpace="-S ''"
|
|
136
184
|
fi
|
|
137
185
|
|
|
138
186
|
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
139
|
-
__${
|
|
187
|
+
__${name.value}_debug "Activating keep order."
|
|
140
188
|
keepOrder="-V"
|
|
141
189
|
fi
|
|
142
190
|
|
|
@@ -153,17 +201,17 @@ _${p.value}() {
|
|
|
153
201
|
done
|
|
154
202
|
filteringCmd+=" \\\${flagPrefix}"
|
|
155
203
|
|
|
156
|
-
__${
|
|
204
|
+
__${name.value}_debug "File filtering command: $filteringCmd"
|
|
157
205
|
_arguments '*:filename:'"$filteringCmd"
|
|
158
206
|
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
|
159
207
|
# File completion for directories only
|
|
160
208
|
local subdir
|
|
161
209
|
subdir="\\\${completions[1]}"
|
|
162
210
|
if [ -n "$subdir" ]; then
|
|
163
|
-
__${
|
|
211
|
+
__${name.value}_debug "Listing directories in $subdir"
|
|
164
212
|
pushd "\\\${subdir}" >/dev/null 2>&1
|
|
165
213
|
else
|
|
166
|
-
__${
|
|
214
|
+
__${name.value}_debug "Listing directories in ."
|
|
167
215
|
fi
|
|
168
216
|
|
|
169
217
|
local result
|
|
@@ -174,17 +222,17 @@ _${p.value}() {
|
|
|
174
222
|
fi
|
|
175
223
|
return $result
|
|
176
224
|
else
|
|
177
|
-
__${
|
|
225
|
+
__${name.value}_debug "Calling _describe"
|
|
178
226
|
if eval _describe $keepOrder "completions" completions -Q \\\${flagPrefix} \\\${noSpace}; then
|
|
179
|
-
__${
|
|
227
|
+
__${name.value}_debug "_describe found some completions"
|
|
180
228
|
|
|
181
229
|
# Return the success of having called _describe
|
|
182
230
|
return 0
|
|
183
231
|
else
|
|
184
|
-
__${
|
|
185
|
-
__${
|
|
232
|
+
__${name.value}_debug "_describe did not find completions."
|
|
233
|
+
__${name.value}_debug "Checking if we should do file completion."
|
|
186
234
|
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
|
187
|
-
__${
|
|
235
|
+
__${name.value}_debug "deactivating file completion"
|
|
188
236
|
|
|
189
237
|
# Return 0 to indicate completion is finished and prevent zsh from
|
|
190
238
|
# trying other completion algorithms (which could cause hanging).
|
|
@@ -192,7 +240,7 @@ _${p.value}() {
|
|
|
192
240
|
return 0
|
|
193
241
|
else
|
|
194
242
|
# Perform file completion
|
|
195
|
-
__${
|
|
243
|
+
__${name.value}_debug "Activating file completion"
|
|
196
244
|
|
|
197
245
|
# We must return the result of this command, so it must be the
|
|
198
246
|
# last command, or else we must store its result to return it.
|
|
@@ -203,10 +251,18 @@ _${p.value}() {
|
|
|
203
251
|
}
|
|
204
252
|
|
|
205
253
|
# don't run the completion function when being sourced or eval-ed
|
|
206
|
-
if [ "\\\${funcstack[1]}" = "_${
|
|
207
|
-
_${
|
|
254
|
+
if [ "\\\${funcstack[1]}" = "_${name.value}" ]; then
|
|
255
|
+
_${name.value}
|
|
208
256
|
fi
|
|
209
|
-
\`;
|
|
257
|
+
\`; `;
|
|
258
|
+
}
|
|
259
|
+
}),
|
|
260
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
261
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
262
|
+
"export": true,
|
|
263
|
+
"const": true,
|
|
264
|
+
name: "SHELL_COMPLETIONS_DISPLAY",
|
|
265
|
+
initializer: _alloy_js_core.code` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
210
266
|
if (!line.trim()) {
|
|
211
267
|
return "";
|
|
212
268
|
}
|
|
@@ -227,4 +283,12 @@ fi
|
|
|
227
283
|
.replaceAll(/__\\w/g, bold(magentaBright("$&")))
|
|
228
284
|
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
229
285
|
|
|
230
|
-
}).join("\\n"); `
|
|
286
|
+
}).join("\\n"); `
|
|
287
|
+
})
|
|
288
|
+
];
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
//#endregion
|
|
294
|
+
exports.ZshCompletionsShared = ZshCompletionsShared;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
|
-
|
|
3
1
|
//#region src/components/zsh-shared.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* The Zsh Completions generation for the Shell Shock project.
|
|
6
4
|
*/
|
|
7
|
-
declare function ZshCompletionsShared():
|
|
5
|
+
declare function ZshCompletionsShared(): import("@alloy-js/core").Children;
|
|
8
6
|
//#endregion
|
|
9
7
|
export { ZshCompletionsShared };
|
|
10
8
|
//# sourceMappingURL=zsh-shared.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zsh-shared.d.cts","names":[],"sources":["../../src/components/zsh-shared.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"zsh-shared.d.cts","names":[],"sources":["../../src/components/zsh-shared.tsx"],"mappings":";;AAiCA;;iBAAgB,oBAAA,6BAAoB,QAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
|
-
|
|
3
1
|
//#region src/components/zsh-shared.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* The Zsh Completions generation for the Shell Shock project.
|
|
6
4
|
*/
|
|
7
|
-
declare function ZshCompletionsShared():
|
|
5
|
+
declare function ZshCompletionsShared(): import("@alloy-js/core").Children;
|
|
8
6
|
//#endregion
|
|
9
7
|
export { ZshCompletionsShared };
|
|
10
8
|
//# sourceMappingURL=zsh-shared.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zsh-shared.d.mts","names":[],"sources":["../../src/components/zsh-shared.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"zsh-shared.d.mts","names":[],"sources":["../../src/components/zsh-shared.tsx"],"mappings":""}
|
|
@@ -1,35 +1,82 @@
|
|
|
1
|
-
import{EXEC_COMMAND
|
|
1
|
+
import { EXEC_COMMAND } from "../helpers/complete-command.mjs";
|
|
2
|
+
import { CompletionDirective } from "../helpers/completion-directive-constants.mjs";
|
|
3
|
+
import "../helpers/index.mjs";
|
|
4
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import { getAppBin } 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 { snakeCase } from "@stryke/string-format/snake-case";
|
|
13
|
+
|
|
14
|
+
//#region src/components/zsh-shared.tsx
|
|
15
|
+
/**
|
|
16
|
+
* The Zsh Completions generation for the Shell Shock project.
|
|
17
|
+
*/
|
|
18
|
+
function ZshCompletionsShared() {
|
|
19
|
+
const context = usePowerlines();
|
|
20
|
+
const bin = computed(() => getAppBin(context));
|
|
21
|
+
const name = computed(() => snakeCase(bin.value));
|
|
22
|
+
return createComponent(TypescriptFile, {
|
|
23
|
+
get path() {
|
|
24
|
+
return joinPaths(context.entryPath, "completions", "zsh", "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` \`__${name.value}_debug() {
|
|
2
49
|
local file="$BASH_COMP_DEBUG_FILE"
|
|
3
50
|
if [[ -n \\\${file} ]]; then
|
|
4
51
|
echo "$*" >> "\\\${file}"
|
|
5
52
|
fi
|
|
6
53
|
}
|
|
7
54
|
|
|
8
|
-
_${
|
|
9
|
-
local shellCompDirectiveError=${
|
|
10
|
-
local shellCompDirectiveNoSpace=${
|
|
11
|
-
local shellCompDirectiveNoFileComp=${
|
|
12
|
-
local shellCompDirectiveFilterFileExt=${
|
|
13
|
-
local shellCompDirectiveFilterDirs=${
|
|
14
|
-
local shellCompDirectiveKeepOrder=${
|
|
55
|
+
_${name.value}() {
|
|
56
|
+
local shellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}
|
|
57
|
+
local shellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}
|
|
58
|
+
local shellCompDirectiveNoFileComp=${CompletionDirective.CompletionDirectiveNoFileComp}
|
|
59
|
+
local shellCompDirectiveFilterFileExt=${CompletionDirective.CompletionDirectiveFilterFileExt}
|
|
60
|
+
local shellCompDirectiveFilterDirs=${CompletionDirective.CompletionDirectiveFilterDirs}
|
|
61
|
+
local shellCompDirectiveKeepOrder=${CompletionDirective.CompletionDirectiveKeepOrder}
|
|
15
62
|
|
|
16
63
|
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
|
17
64
|
local -a completions
|
|
18
65
|
|
|
19
|
-
__${
|
|
20
|
-
__${
|
|
66
|
+
__${name.value}_debug "\\n========= starting completion logic =========="
|
|
67
|
+
__${name.value}_debug "CURRENT: \\\${CURRENT}, words[*]: \\\${words[*]}"
|
|
21
68
|
|
|
22
69
|
# The user could have moved the cursor backwards on the command-line.
|
|
23
70
|
# We need to trigger completion from the $CURRENT location, so we need
|
|
24
71
|
# to truncate the command-line ($words) up to the $CURRENT location.
|
|
25
72
|
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
|
|
26
73
|
words=( "\\\${=words[1,CURRENT]}" )
|
|
27
|
-
__${
|
|
74
|
+
__${name.value}_debug "Truncated words[*]: \\\${words[*]},"
|
|
28
75
|
|
|
29
76
|
lastParam=\\\${words[-1]}
|
|
30
77
|
lastChar=\\\${lastParam[-1]}
|
|
31
|
-
__${
|
|
32
|
-
# For zsh, when completing a flag with an = (e.g., ${
|
|
78
|
+
__${name.value}_debug "lastParam: \\\${lastParam}, lastChar: \\\${lastChar}"
|
|
79
|
+
# For zsh, when completing a flag with an = (e.g., ${bin.value} -n=<TAB>)
|
|
33
80
|
# completions must be prefixed with the flag
|
|
34
81
|
setopt local_options BASH_REMATCH
|
|
35
82
|
if [[ "\\\${lastParam}" =~ '-.*=' ]]; then
|
|
@@ -42,7 +89,7 @@ _${m.value}() {
|
|
|
42
89
|
if [ "\\\${lastChar}" = "" ]; then
|
|
43
90
|
# If the last parameter is complete (there is a space following it)
|
|
44
91
|
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
45
|
-
__${
|
|
92
|
+
__${name.value}_debug "Adding extra empty parameter"
|
|
46
93
|
args_to_quote+=("")
|
|
47
94
|
fi
|
|
48
95
|
|
|
@@ -50,20 +97,20 @@ _${m.value}() {
|
|
|
50
97
|
local quoted_args=("\\\${(@q)args_to_quote}")
|
|
51
98
|
|
|
52
99
|
# Join the main command and the quoted arguments into a single string for eval
|
|
53
|
-
requestComp="${
|
|
100
|
+
requestComp="${EXEC_COMMAND} complete -- \\\${quoted_args[*]}"
|
|
54
101
|
|
|
55
|
-
__${
|
|
102
|
+
__${name.value}_debug "About to call: eval \\\${requestComp}"
|
|
56
103
|
|
|
57
104
|
# Use eval to handle any environment variables and such
|
|
58
105
|
out=$(eval \\\${requestComp} 2>/dev/null)
|
|
59
|
-
__${
|
|
106
|
+
__${name.value}_debug "completion output: \\\${out}"
|
|
60
107
|
|
|
61
108
|
# Extract the directive integer following a : from the last line
|
|
62
109
|
local lastLine
|
|
63
110
|
while IFS='\n' read -r line; do
|
|
64
111
|
lastLine=\\\${line}
|
|
65
112
|
done < <(printf "%s\n" "\\\${out[@]}")
|
|
66
|
-
__${
|
|
113
|
+
__${name.value}_debug "last line: \\\${lastLine}"
|
|
67
114
|
|
|
68
115
|
if [ "\\\${lastLine[1]}" = : ]; then
|
|
69
116
|
directive=\\\${lastLine[2,-1]}
|
|
@@ -73,16 +120,16 @@ _${m.value}() {
|
|
|
73
120
|
out=\\\${out[1,-$suffix]}
|
|
74
121
|
else
|
|
75
122
|
# There is no directive specified. Leave $out as is.
|
|
76
|
-
__${
|
|
123
|
+
__${name.value}_debug "No directive found. Setting to default"
|
|
77
124
|
directive=0
|
|
78
125
|
fi
|
|
79
126
|
|
|
80
|
-
__${
|
|
81
|
-
__${
|
|
82
|
-
__${
|
|
127
|
+
__${name.value}_debug "directive: \\\${directive}"
|
|
128
|
+
__${name.value}_debug "completions: \\\${out}"
|
|
129
|
+
__${name.value}_debug "flagPrefix: \\\${flagPrefix}"
|
|
83
130
|
|
|
84
131
|
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
|
85
|
-
__${
|
|
132
|
+
__${name.value}_debug "Completion received error. Ignoring completions."
|
|
86
133
|
return
|
|
87
134
|
fi
|
|
88
135
|
|
|
@@ -93,11 +140,11 @@ _${m.value}() {
|
|
|
93
140
|
while IFS='\n' read -r comp; do
|
|
94
141
|
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
95
142
|
if [ "\\\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
96
|
-
__${
|
|
143
|
+
__${name.value}_debug "ActiveHelp found: $comp"
|
|
97
144
|
comp="\\\${comp[$startIndex,-1]}"
|
|
98
145
|
if [ -n "$comp" ]; then
|
|
99
146
|
compadd -x "\\\${comp}"
|
|
100
|
-
__${
|
|
147
|
+
__${name.value}_debug "ActiveHelp will need delimiter"
|
|
101
148
|
hasActiveHelp=1
|
|
102
149
|
fi
|
|
103
150
|
continue
|
|
@@ -113,7 +160,7 @@ _${m.value}() {
|
|
|
113
160
|
local tab="$(printf '\\t')"
|
|
114
161
|
comp=\\\${comp//$tab/:}
|
|
115
162
|
|
|
116
|
-
__${
|
|
163
|
+
__${name.value}_debug "Adding completion: \\\${comp}"
|
|
117
164
|
completions+=\\\${comp}
|
|
118
165
|
lastComp=$comp
|
|
119
166
|
fi
|
|
@@ -124,19 +171,19 @@ _${m.value}() {
|
|
|
124
171
|
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
125
172
|
if [ $hasActiveHelp -eq 1 ]; then
|
|
126
173
|
if [ \\\${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
127
|
-
__${
|
|
174
|
+
__${name.value}_debug "Adding activeHelp delimiter"
|
|
128
175
|
compadd -x "--"
|
|
129
176
|
hasActiveHelp=0
|
|
130
177
|
fi
|
|
131
178
|
fi
|
|
132
179
|
|
|
133
180
|
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
|
134
|
-
__${
|
|
181
|
+
__${name.value}_debug "Activating nospace."
|
|
135
182
|
noSpace="-S ''"
|
|
136
183
|
fi
|
|
137
184
|
|
|
138
185
|
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
139
|
-
__${
|
|
186
|
+
__${name.value}_debug "Activating keep order."
|
|
140
187
|
keepOrder="-V"
|
|
141
188
|
fi
|
|
142
189
|
|
|
@@ -153,17 +200,17 @@ _${m.value}() {
|
|
|
153
200
|
done
|
|
154
201
|
filteringCmd+=" \\\${flagPrefix}"
|
|
155
202
|
|
|
156
|
-
__${
|
|
203
|
+
__${name.value}_debug "File filtering command: $filteringCmd"
|
|
157
204
|
_arguments '*:filename:'"$filteringCmd"
|
|
158
205
|
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
|
159
206
|
# File completion for directories only
|
|
160
207
|
local subdir
|
|
161
208
|
subdir="\\\${completions[1]}"
|
|
162
209
|
if [ -n "$subdir" ]; then
|
|
163
|
-
__${
|
|
210
|
+
__${name.value}_debug "Listing directories in $subdir"
|
|
164
211
|
pushd "\\\${subdir}" >/dev/null 2>&1
|
|
165
212
|
else
|
|
166
|
-
__${
|
|
213
|
+
__${name.value}_debug "Listing directories in ."
|
|
167
214
|
fi
|
|
168
215
|
|
|
169
216
|
local result
|
|
@@ -174,17 +221,17 @@ _${m.value}() {
|
|
|
174
221
|
fi
|
|
175
222
|
return $result
|
|
176
223
|
else
|
|
177
|
-
__${
|
|
224
|
+
__${name.value}_debug "Calling _describe"
|
|
178
225
|
if eval _describe $keepOrder "completions" completions -Q \\\${flagPrefix} \\\${noSpace}; then
|
|
179
|
-
__${
|
|
226
|
+
__${name.value}_debug "_describe found some completions"
|
|
180
227
|
|
|
181
228
|
# Return the success of having called _describe
|
|
182
229
|
return 0
|
|
183
230
|
else
|
|
184
|
-
__${
|
|
185
|
-
__${
|
|
231
|
+
__${name.value}_debug "_describe did not find completions."
|
|
232
|
+
__${name.value}_debug "Checking if we should do file completion."
|
|
186
233
|
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
|
187
|
-
__${
|
|
234
|
+
__${name.value}_debug "deactivating file completion"
|
|
188
235
|
|
|
189
236
|
# Return 0 to indicate completion is finished and prevent zsh from
|
|
190
237
|
# trying other completion algorithms (which could cause hanging).
|
|
@@ -192,7 +239,7 @@ _${m.value}() {
|
|
|
192
239
|
return 0
|
|
193
240
|
else
|
|
194
241
|
# Perform file completion
|
|
195
|
-
__${
|
|
242
|
+
__${name.value}_debug "Activating file completion"
|
|
196
243
|
|
|
197
244
|
# We must return the result of this command, so it must be the
|
|
198
245
|
# last command, or else we must store its result to return it.
|
|
@@ -203,10 +250,18 @@ _${m.value}() {
|
|
|
203
250
|
}
|
|
204
251
|
|
|
205
252
|
# don't run the completion function when being sourced or eval-ed
|
|
206
|
-
if [ "\\\${funcstack[1]}" = "_${
|
|
207
|
-
_${
|
|
253
|
+
if [ "\\\${funcstack[1]}" = "_${name.value}" ]; then
|
|
254
|
+
_${name.value}
|
|
208
255
|
fi
|
|
209
|
-
\`;
|
|
256
|
+
\`; `;
|
|
257
|
+
}
|
|
258
|
+
}),
|
|
259
|
+
createComponent(Spacing, {}),
|
|
260
|
+
createComponent(VarDeclaration, {
|
|
261
|
+
"export": true,
|
|
262
|
+
"const": true,
|
|
263
|
+
name: "SHELL_COMPLETIONS_DISPLAY",
|
|
264
|
+
initializer: code` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
210
265
|
if (!line.trim()) {
|
|
211
266
|
return "";
|
|
212
267
|
}
|
|
@@ -227,5 +282,13 @@ fi
|
|
|
227
282
|
.replaceAll(/__\\w/g, bold(magentaBright("$&")))
|
|
228
283
|
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
229
284
|
|
|
230
|
-
}).join("\\n"); `
|
|
285
|
+
}).join("\\n"); `
|
|
286
|
+
})
|
|
287
|
+
];
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
//#endregion
|
|
293
|
+
export { ZshCompletionsShared };
|
|
231
294
|
//# sourceMappingURL=zsh-shared.mjs.map
|