@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,25 +1,72 @@
|
|
|
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/fish-shared.tsx
|
|
15
|
+
/**
|
|
16
|
+
* The Fish Completions generation for the Shell Shock project.
|
|
17
|
+
*/
|
|
18
|
+
function FishCompletionsShared() {
|
|
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", "fish", "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` \`function __${name.value}_debug
|
|
2
49
|
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
3
50
|
if test -n "$file"
|
|
4
51
|
echo "$argv" >> $file
|
|
5
52
|
end
|
|
6
53
|
end
|
|
7
54
|
|
|
8
|
-
function __${
|
|
9
|
-
__${
|
|
55
|
+
function __${name.value}_perform_completion
|
|
56
|
+
__${name.value}_debug "Starting __${name.value}_perform_completion"
|
|
10
57
|
|
|
11
58
|
# Extract all args except the last one
|
|
12
59
|
set -l args (commandline -opc)
|
|
13
60
|
# Extract the last arg and escape it in case it is a space or wildcard
|
|
14
61
|
set -l lastArg (string escape -- (commandline -ct))
|
|
15
62
|
|
|
16
|
-
__${
|
|
17
|
-
__${
|
|
63
|
+
__${name.value}_debug "args: $args"
|
|
64
|
+
__${name.value}_debug "last arg: $lastArg"
|
|
18
65
|
|
|
19
66
|
# Build the completion request command
|
|
20
|
-
set -l requestComp "${
|
|
67
|
+
set -l requestComp "${EXEC_COMMAND} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
|
|
21
68
|
|
|
22
|
-
__${
|
|
69
|
+
__${name.value}_debug "Calling $requestComp"
|
|
23
70
|
set -l results (eval $requestComp 2> /dev/null)
|
|
24
71
|
|
|
25
72
|
# Some programs may output extra empty lines after the directive.
|
|
@@ -42,9 +89,9 @@ function __${m.value}_perform_completion
|
|
|
42
89
|
# completions must be prefixed with the flag
|
|
43
90
|
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
|
|
44
91
|
|
|
45
|
-
__${
|
|
46
|
-
__${
|
|
47
|
-
__${
|
|
92
|
+
__${name.value}_debug "Comps: $comps"
|
|
93
|
+
__${name.value}_debug "DirectiveLine: $directiveLine"
|
|
94
|
+
__${name.value}_debug "flagPrefix: $flagPrefix"
|
|
48
95
|
|
|
49
96
|
for comp in $comps
|
|
50
97
|
printf "%s%s\\n" "$flagPrefix" "$comp"
|
|
@@ -53,96 +100,96 @@ function __${m.value}_perform_completion
|
|
|
53
100
|
printf "%s\\n" "$directiveLine"
|
|
54
101
|
end
|
|
55
102
|
|
|
56
|
-
# This function limits calls to __${
|
|
57
|
-
function __${
|
|
58
|
-
__${
|
|
103
|
+
# This function limits calls to __${name.value}_perform_completion, by caching the result
|
|
104
|
+
function __${name.value}_perform_completion_once
|
|
105
|
+
__${name.value}_debug "Starting __${name.value}_perform_completion_once"
|
|
59
106
|
|
|
60
|
-
if test -n "$__${
|
|
61
|
-
__${
|
|
107
|
+
if test -n "$__${name.value}_perform_completion_once_result"
|
|
108
|
+
__${name.value}_debug "Seems like a valid result already exists, skipping __${name.value}_perform_completion"
|
|
62
109
|
return 0
|
|
63
110
|
end
|
|
64
111
|
|
|
65
|
-
set --global __${
|
|
66
|
-
if test -z "$__${
|
|
67
|
-
__${
|
|
112
|
+
set --global __${name.value}_perform_completion_once_result (__${name.value}_perform_completion)
|
|
113
|
+
if test -z "$__${name.value}_perform_completion_once_result"
|
|
114
|
+
__${name.value}_debug "No completions, probably due to a failure"
|
|
68
115
|
return 1
|
|
69
116
|
end
|
|
70
117
|
|
|
71
|
-
__${
|
|
118
|
+
__${name.value}_debug "Performed completions and set __${name.value}_perform_completion_once_result"
|
|
72
119
|
return 0
|
|
73
120
|
end
|
|
74
121
|
|
|
75
122
|
# This function is used to clear the cached result after completions are run
|
|
76
|
-
function __${
|
|
77
|
-
__${
|
|
78
|
-
__${
|
|
79
|
-
set --erase __${
|
|
80
|
-
__${
|
|
123
|
+
function __${name.value}_clear_perform_completion_once_result
|
|
124
|
+
__${name.value}_debug ""
|
|
125
|
+
__${name.value}_debug "========= clearing previously set __${name.value}_perform_completion_once_result variable =========="
|
|
126
|
+
set --erase __${name.value}_perform_completion_once_result
|
|
127
|
+
__${name.value}_debug "Successfully erased the variable __${name.value}_perform_completion_once_result"
|
|
81
128
|
end
|
|
82
129
|
|
|
83
|
-
function __${
|
|
84
|
-
__${
|
|
85
|
-
__${
|
|
130
|
+
function __${name.value}_requires_order_preservation
|
|
131
|
+
__${name.value}_debug ""
|
|
132
|
+
__${name.value}_debug "========= checking if order preservation is required =========="
|
|
86
133
|
|
|
87
|
-
__${
|
|
88
|
-
if test -z "$__${
|
|
89
|
-
__${
|
|
134
|
+
__${name.value}_perform_completion_once
|
|
135
|
+
if test -z "$__${name.value}_perform_completion_once_result"
|
|
136
|
+
__${name.value}_debug "Error determining if order preservation is required"
|
|
90
137
|
return 1
|
|
91
138
|
end
|
|
92
139
|
|
|
93
|
-
set -l directive (string sub --start 2 $__${
|
|
94
|
-
__${
|
|
140
|
+
set -l directive (string sub --start 2 $__${name.value}_perform_completion_once_result[-1])
|
|
141
|
+
__${name.value}_debug "Directive is: $directive"
|
|
95
142
|
|
|
96
|
-
set -l shellCompDirectiveKeepOrder ${
|
|
143
|
+
set -l shellCompDirectiveKeepOrder ${CompletionDirective.CompletionDirectiveKeepOrder}
|
|
97
144
|
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
|
|
98
|
-
__${
|
|
145
|
+
__${name.value}_debug "Keeporder is: $keeporder"
|
|
99
146
|
|
|
100
147
|
if test $keeporder -ne 0
|
|
101
|
-
__${
|
|
148
|
+
__${name.value}_debug "This does require order preservation"
|
|
102
149
|
return 0
|
|
103
150
|
end
|
|
104
151
|
|
|
105
|
-
__${
|
|
152
|
+
__${name.value}_debug "This doesn't require order preservation"
|
|
106
153
|
return 1
|
|
107
154
|
end
|
|
108
155
|
|
|
109
156
|
# This function does two things:
|
|
110
|
-
# - Obtain the completions and store them in the global __${
|
|
157
|
+
# - Obtain the completions and store them in the global __${name.value}_comp_results
|
|
111
158
|
# - Return false if file completion should be performed
|
|
112
|
-
function __${
|
|
113
|
-
__${
|
|
114
|
-
__${
|
|
159
|
+
function __${name.value}_prepare_completions
|
|
160
|
+
__${name.value}_debug ""
|
|
161
|
+
__${name.value}_debug "========= starting completion logic =========="
|
|
115
162
|
|
|
116
163
|
# Start fresh
|
|
117
|
-
set --erase __${
|
|
164
|
+
set --erase __${name.value}_comp_results
|
|
118
165
|
|
|
119
|
-
__${
|
|
120
|
-
__${
|
|
166
|
+
__${name.value}_perform_completion_once
|
|
167
|
+
__${name.value}_debug "Completion results: $__${name.value}_perform_completion_once_result"
|
|
121
168
|
|
|
122
|
-
if test -z "$__${
|
|
123
|
-
__${
|
|
169
|
+
if test -z "$__${name.value}_perform_completion_once_result"
|
|
170
|
+
__${name.value}_debug "No completion, probably due to a failure"
|
|
124
171
|
# Might as well do file completion, in case it helps
|
|
125
172
|
return 1
|
|
126
173
|
end
|
|
127
174
|
|
|
128
|
-
set -l directive (string sub --start 2 $__${
|
|
129
|
-
set --global __${
|
|
175
|
+
set -l directive (string sub --start 2 $__${name.value}_perform_completion_once_result[-1])
|
|
176
|
+
set --global __${name.value}_comp_results $__${name.value}_perform_completion_once_result[1..-2]
|
|
130
177
|
|
|
131
|
-
__${
|
|
132
|
-
__${
|
|
178
|
+
__${name.value}_debug "Completions are: $__${name.value}_comp_results"
|
|
179
|
+
__${name.value}_debug "Directive is: $directive"
|
|
133
180
|
|
|
134
|
-
set -l shellCompDirectiveError ${
|
|
135
|
-
set -l shellCompDirectiveNoSpace ${
|
|
136
|
-
set -l shellCompDirectiveNoFileComp ${
|
|
137
|
-
set -l shellCompDirectiveFilterFileExt ${
|
|
138
|
-
set -l shellCompDirectiveFilterDirs ${
|
|
181
|
+
set -l shellCompDirectiveError ${CompletionDirective.CompletionDirectiveError}
|
|
182
|
+
set -l shellCompDirectiveNoSpace ${CompletionDirective.CompletionDirectiveNoSpace}
|
|
183
|
+
set -l shellCompDirectiveNoFileComp ${CompletionDirective.CompletionDirectiveNoFileComp}
|
|
184
|
+
set -l shellCompDirectiveFilterFileExt ${CompletionDirective.CompletionDirectiveFilterFileExt}
|
|
185
|
+
set -l shellCompDirectiveFilterDirs ${CompletionDirective.CompletionDirectiveFilterDirs}
|
|
139
186
|
if test -z "$directive"
|
|
140
187
|
set directive 0
|
|
141
188
|
end
|
|
142
189
|
|
|
143
190
|
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
|
|
144
191
|
if test $compErr -eq 1
|
|
145
|
-
__${
|
|
192
|
+
__${name.value}_debug "Received error directive: aborting."
|
|
146
193
|
# Might as well do file completion, in case it helps
|
|
147
194
|
return 1
|
|
148
195
|
end
|
|
@@ -150,7 +197,7 @@ function __${m.value}_prepare_completions
|
|
|
150
197
|
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
|
|
151
198
|
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
|
|
152
199
|
if test $filefilter -eq 1; or test $dirfilter -eq 1
|
|
153
|
-
__${
|
|
200
|
+
__${name.value}_debug "File extension filtering or directory filtering not supported"
|
|
154
201
|
# Do full file completion instead
|
|
155
202
|
return 1
|
|
156
203
|
end
|
|
@@ -158,7 +205,7 @@ function __${m.value}_prepare_completions
|
|
|
158
205
|
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
|
|
159
206
|
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
|
|
160
207
|
|
|
161
|
-
__${
|
|
208
|
+
__${name.value}_debug "nospace: $nospace, nofiles: $nofiles"
|
|
162
209
|
|
|
163
210
|
# If we want to prevent a space, or if file completion is NOT disabled,
|
|
164
211
|
# we need to count the number of valid completions.
|
|
@@ -167,22 +214,22 @@ function __${m.value}_prepare_completions
|
|
|
167
214
|
# criteria than the prefix.
|
|
168
215
|
if test $nospace -ne 0; or test $nofiles -eq 0
|
|
169
216
|
set -l prefix (commandline -t | string escape --style=regex)
|
|
170
|
-
__${
|
|
217
|
+
__${name.value}_debug "prefix: $prefix"
|
|
171
218
|
|
|
172
|
-
set -l completions (string match -r -- "^$prefix.*" $__${
|
|
173
|
-
set --global __${
|
|
174
|
-
__${
|
|
219
|
+
set -l completions (string match -r -- "^$prefix.*" $__${name.value}_comp_results)
|
|
220
|
+
set --global __${name.value}_comp_results $completions
|
|
221
|
+
__${name.value}_debug "Filtered completions are: $__${name.value}_comp_results"
|
|
175
222
|
|
|
176
223
|
# Important not to quote the variable for count to work
|
|
177
|
-
set -l numComps (count $__${
|
|
178
|
-
__${
|
|
224
|
+
set -l numComps (count $__${name.value}_comp_results)
|
|
225
|
+
__${name.value}_debug "numComps: $numComps"
|
|
179
226
|
|
|
180
227
|
if test $numComps -eq 1; and test $nospace -ne 0
|
|
181
228
|
# We must first split on \\t to get rid of the descriptions to be
|
|
182
229
|
# able to check what the actual completion will be.
|
|
183
230
|
# We don't need descriptions anyway since there is only a single
|
|
184
231
|
# real completion which the shell will expand immediately.
|
|
185
|
-
set -l split (string split --max 1 "\\t" $__${
|
|
232
|
+
set -l split (string split --max 1 "\\t" $__${name.value}_comp_results[1])
|
|
186
233
|
|
|
187
234
|
# Fish won't add a space if the completion ends with any
|
|
188
235
|
# of the following characters: @=/:.,
|
|
@@ -190,16 +237,16 @@ function __${m.value}_prepare_completions
|
|
|
190
237
|
if not string match -r -q "[@=/:.,]" -- "$lastChar"
|
|
191
238
|
# In other cases, to support the "nospace" directive we trick the shell
|
|
192
239
|
# by outputting an extra, longer completion.
|
|
193
|
-
__${
|
|
194
|
-
set --global __${
|
|
195
|
-
__${
|
|
240
|
+
__${name.value}_debug "Adding second completion to perform nospace directive"
|
|
241
|
+
set --global __${name.value}_comp_results $split[1] $split[1].
|
|
242
|
+
__${name.value}_debug "Completions are now: $__${name.value}_comp_results"
|
|
196
243
|
end
|
|
197
244
|
end
|
|
198
245
|
|
|
199
246
|
if test $numComps -eq 0; and test $nofiles -eq 0
|
|
200
247
|
# To be consistent with bash and zsh, we only trigger file
|
|
201
248
|
# completion when there are no other completions
|
|
202
|
-
__${
|
|
249
|
+
__${name.value}_debug "Requesting file completion"
|
|
203
250
|
return 1
|
|
204
251
|
end
|
|
205
252
|
end
|
|
@@ -211,24 +258,32 @@ end
|
|
|
211
258
|
# so we can properly delete any completions provided by another script.
|
|
212
259
|
# Only do this if the program can be found, or else fish may print some errors; besides,
|
|
213
260
|
# the existing completions will only be loaded if the program can be found.
|
|
214
|
-
if type -q "${
|
|
261
|
+
if type -q "${bin.value}"
|
|
215
262
|
# The space after the program name is essential to trigger completion for the program
|
|
216
263
|
# and not completion of the program name itself.
|
|
217
264
|
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
|
|
218
|
-
complete --do-complete "${
|
|
265
|
+
complete --do-complete "${bin.value} " > /dev/null 2>&1
|
|
219
266
|
end
|
|
220
267
|
|
|
221
268
|
# Remove any pre-existing completions for the program since we will be handling all of them.
|
|
222
|
-
complete -c ${
|
|
269
|
+
complete -c ${bin.value} -e
|
|
223
270
|
# This will get called after the two calls below and clear the cached result
|
|
224
|
-
complete -c ${
|
|
225
|
-
# The call to __${
|
|
271
|
+
complete -c ${bin.value} -n '__${name.value}_clear_perform_completion_once_result'
|
|
272
|
+
# The call to __${name.value}_prepare_completions will setup __${name.value}_comp_results
|
|
226
273
|
# which provides the program's completion choices.
|
|
227
274
|
# If this doesn't require order preservation, we don't use the -k flag
|
|
228
|
-
complete -c ${
|
|
275
|
+
complete -c ${getAppBin(context)} -n 'not __${name.value}_requires_order_preservation && __${name.value}_prepare_completions' -f -a '$__${name.value}_comp_results'
|
|
229
276
|
# Otherwise we use the -k flag
|
|
230
|
-
complete -k -c ${
|
|
231
|
-
\`;
|
|
277
|
+
complete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && __${name.value}_prepare_completions' -f -a '$__${name.value}_comp_results'
|
|
278
|
+
\`; `;
|
|
279
|
+
}
|
|
280
|
+
}),
|
|
281
|
+
createComponent(Spacing, {}),
|
|
282
|
+
createComponent(VarDeclaration, {
|
|
283
|
+
"export": true,
|
|
284
|
+
"const": true,
|
|
285
|
+
name: "SHELL_COMPLETIONS_DISPLAY",
|
|
286
|
+
initializer: code` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
232
287
|
if (!line.trim()) {
|
|
233
288
|
return "";
|
|
234
289
|
}
|
|
@@ -249,5 +304,13 @@ complete -k -c ${p.value} -n '__${m.value}_requires_order_preservation && __${m.
|
|
|
249
304
|
.replaceAll(/\\s__\\w/g, bold(magentaBright("$&")))
|
|
250
305
|
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
251
306
|
|
|
252
|
-
}).join("\\n"); `
|
|
307
|
+
}).join("\\n"); `
|
|
308
|
+
})
|
|
309
|
+
];
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
//#endregion
|
|
315
|
+
export { FishCompletionsShared };
|
|
253
316
|
//# sourceMappingURL=fish-shared.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fish-shared.mjs","names":[],"sources":["../../src/components/fish-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 } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions generation for the Shell Shock project.\n */\nexport function FishCompletionsShared() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n const name = computed(() => snakeCase(bin.value));\n\n return (\n <TypescriptFile\n path={joinPaths(context.entryPath, \"completions\", \"fish\", \"shared.ts\")}\n builtinImports={{\n console: [\n \"white\",\n \"green\",\n \"red\",\n \"bold\",\n \"cyan\",\n \"gray\",\n \"magenta\",\n \"magentaBright\",\n \"greenBright\",\n \"redBright\",\n \"cyanBright\",\n \"dim\"\n ]\n }}>\n <Spacing />\n <VarDeclaration\n const\n export\n name=\"SHELL_COMPLETIONS\"\n initializer={code` \\`function __${name.value}_debug\n set -l file \"$BASH_COMP_DEBUG_FILE\"\n if test -n \"$file\"\n echo \"$argv\" >> $file\n end\nend\n\nfunction __${name.value}_perform_completion\n __${name.value}_debug \"Starting __${name.value}_perform_completion\"\n\n # Extract all args except the last one\n set -l args (commandline -opc)\n # Extract the last arg and escape it in case it is a space or wildcard\n set -l lastArg (string escape -- (commandline -ct))\n\n __${name.value}_debug \"args: $args\"\n __${name.value}_debug \"last arg: $lastArg\"\n\n # Build the completion request command\n set -l requestComp \"${EXEC_COMMAND} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg\"\n\n __${name.value}_debug \"Calling $requestComp\"\n set -l results (eval $requestComp 2> /dev/null)\n\n # Some programs may output extra empty lines after the directive.\n # Let's ignore them or else it will break completion.\n # Ref: https://github.com/spf13/cobra/issues/1279\n for line in $results[-1..1]\n if test (string trim -- $line) = \"\"\n # Found an empty line, remove it\n set results $results[1..-2]\n else\n # Found non-empty line, we have our proper output\n break\n end\n end\n\n set -l comps $results[1..-2]\n set -l directiveLine $results[-1]\n\n # For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)\n # completions must be prefixed with the flag\n set -l flagPrefix (string match -r -- '-.*=' \"$lastArg\")\n\n __${name.value}_debug \"Comps: $comps\"\n __${name.value}_debug \"DirectiveLine: $directiveLine\"\n __${name.value}_debug \"flagPrefix: $flagPrefix\"\n\n for comp in $comps\n printf \"%s%s\\\\n\" \"$flagPrefix\" \"$comp\"\n end\n\n printf \"%s\\\\n\" \"$directiveLine\"\nend\n\n# This function limits calls to __${\n name.value\n }_perform_completion, by caching the result\nfunction __${name.value}_perform_completion_once\n __${name.value}_debug \"Starting __${name.value}_perform_completion_once\"\n\n if test -n \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"Seems like a valid result already exists, skipping __${name.value}_perform_completion\"\n return 0\n end\n\n set --global __${name.value}_perform_completion_once_result (__${\n name.value\n }_perform_completion)\n if test -z \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"No completions, probably due to a failure\"\n return 1\n end\n\n __${name.value}_debug \"Performed completions and set __${\n name.value\n }_perform_completion_once_result\"\n return 0\nend\n\n# This function is used to clear the cached result after completions are run\nfunction __${name.value}_clear_perform_completion_once_result\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= clearing previously set __${\n name.value\n }_perform_completion_once_result variable ==========\"\n set --erase __${name.value}_perform_completion_once_result\n __${name.value}_debug \"Successfully erased the variable __${\n name.value\n }_perform_completion_once_result\"\nend\n\nfunction __${name.value}_requires_order_preservation\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= checking if order preservation is required ==========\"\n\n __${name.value}_perform_completion_once\n if test -z \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"Error determining if order preservation is required\"\n return 1\n end\n\n set -l directive (string sub --start 2 $__${\n name.value\n }_perform_completion_once_result[-1])\n __${name.value}_debug \"Directive is: $directive\"\n\n set -l shellCompDirectiveKeepOrder ${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)\n __${name.value}_debug \"Keeporder is: $keeporder\"\n\n if test $keeporder -ne 0\n __${name.value}_debug \"This does require order preservation\"\n return 0\n end\n\n __${name.value}_debug \"This doesn't require order preservation\"\n return 1\nend\n\n# This function does two things:\n# - Obtain the completions and store them in the global __${\n name.value\n }_comp_results\n# - Return false if file completion should be performed\nfunction __${name.value}_prepare_completions\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= starting completion logic ==========\"\n\n # Start fresh\n set --erase __${name.value}_comp_results\n\n __${name.value}_perform_completion_once\n __${name.value}_debug \"Completion results: $__${\n name.value\n }_perform_completion_once_result\"\n\n if test -z \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"No completion, probably due to a failure\"\n # Might as well do file completion, in case it helps\n return 1\n end\n\n set -l directive (string sub --start 2 $__${\n name.value\n }_perform_completion_once_result[-1])\n set --global __${name.value}_comp_results $__${\n name.value\n }_perform_completion_once_result[1..-2]\n\n __${name.value}_debug \"Completions are: $__${name.value}_comp_results\"\n __${name.value}_debug \"Directive is: $directive\"\n\n set -l shellCompDirectiveError ${\n CompletionDirective.CompletionDirectiveError\n }\n set -l shellCompDirectiveNoSpace ${\n CompletionDirective.CompletionDirectiveNoSpace\n }\n set -l shellCompDirectiveNoFileComp ${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\n set -l shellCompDirectiveFilterFileExt ${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\n set -l shellCompDirectiveFilterDirs ${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\n if test -z \"$directive\"\n set directive 0\n end\n\n set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)\n if test $compErr -eq 1\n __${name.value}_debug \"Received error directive: aborting.\"\n # Might as well do file completion, in case it helps\n return 1\n end\n\n set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)\n set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)\n if test $filefilter -eq 1; or test $dirfilter -eq 1\n __${name.value}_debug \"File extension filtering or directory filtering not supported\"\n # Do full file completion instead\n return 1\n end\n\n set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)\n set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)\n\n __${name.value}_debug \"nospace: $nospace, nofiles: $nofiles\"\n\n # If we want to prevent a space, or if file completion is NOT disabled,\n # we need to count the number of valid completions.\n # To do so, we will filter on prefix as the completions we have received\n # may not already be filtered so as to allow fish to match on different\n # criteria than the prefix.\n if test $nospace -ne 0; or test $nofiles -eq 0\n set -l prefix (commandline -t | string escape --style=regex)\n __${name.value}_debug \"prefix: $prefix\"\n\n set -l completions (string match -r -- \"^$prefix.*\" $__${\n name.value\n }_comp_results)\n set --global __${name.value}_comp_results $completions\n __${name.value}_debug \"Filtered completions are: $__${\n name.value\n }_comp_results\"\n\n # Important not to quote the variable for count to work\n set -l numComps (count $__${name.value}_comp_results)\n __${name.value}_debug \"numComps: $numComps\"\n\n if test $numComps -eq 1; and test $nospace -ne 0\n # We must first split on \\\\t to get rid of the descriptions to be\n # able to check what the actual completion will be.\n # We don't need descriptions anyway since there is only a single\n # real completion which the shell will expand immediately.\n set -l split (string split --max 1 \"\\\\t\" $__${\n name.value\n }_comp_results[1])\n\n # Fish won't add a space if the completion ends with any\n # of the following characters: @=/:.,\n set -l lastChar (string sub -s -1 -- $split)\n if not string match -r -q \"[@=/:.,]\" -- \"$lastChar\"\n # In other cases, to support the \"nospace\" directive we trick the shell\n # by outputting an extra, longer completion.\n __${name.value}_debug \"Adding second completion to perform nospace directive\"\n set --global __${name.value}_comp_results $split[1] $split[1].\n __${name.value}_debug \"Completions are now: $__${\n name.value\n }_comp_results\"\n end\n end\n\n if test $numComps -eq 0; and test $nofiles -eq 0\n # To be consistent with bash and zsh, we only trigger file\n # completion when there are no other completions\n __${name.value}_debug \"Requesting file completion\"\n return 1\n end\n end\n\n return 0\nend\n\n# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves\n# so we can properly delete any completions provided by another script.\n# Only do this if the program can be found, or else fish may print some errors; besides,\n# the existing completions will only be loaded if the program can be found.\nif type -q \"${bin.value}\"\n # The space after the program name is essential to trigger completion for the program\n # and not completion of the program name itself.\n # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.\n complete --do-complete \"${bin.value} \" > /dev/null 2>&1\nend\n\n# Remove any pre-existing completions for the program since we will be handling all of them.\ncomplete -c ${bin.value} -e\n# This will get called after the two calls below and clear the cached result\ncomplete -c ${bin.value} -n '__${name.value}_clear_perform_completion_once_result'\n# The call to __${name.value}_prepare_completions will setup __${\n name.value\n }_comp_results\n# which provides the program's completion choices.\n# If this doesn't require order preservation, we don't use the -k flag\ncomplete -c ${getAppBin(\n context\n )} -n 'not __${name.value}_requires_order_preservation && __${\n name.value\n }_prepare_completions' -f -a '$__${name.value}_comp_results'\n# Otherwise we use the -k flag\ncomplete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && __${\n name.value\n }_prepare_completions' -f -a '$__${name.value}_comp_results'\n\\`; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS_DISPLAY\"\n initializer={code` SHELL_COMPLETIONS.split(\"\\\\n\").map(line => {\n if (!line.trim()) {\n return \"\";\n }\n if (line.trim().startsWith(\"#\")) {\n return \\`\\${dim(line)}\\`;\n }\n\n return white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, green(\"$&\"))\n .replaceAll(/(\\\\\"|\\\\').*(\\\\\"|\\\\')/g, cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|:)/g, bold(gray(\"$&\")))\n .replaceAll(/(function|complete)\\\\s+/g, green(\"$&\"))\n .replaceAll(/(?<=(function|complete)\\\\s+)\\\\w/g, bold(greenBright(\"$&\")))\n .replaceAll(/set\\\\s+/g, red(\"$&\"))\n .replaceAll(/(?<=set\\\\s+)\\\\w/g, bold(redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, bold(cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, green(\"$&\"))\n .replaceAll(/\\\\s__\\\\w/g, bold(magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, bold(magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":"osBAgCA,SAAE,GAAA,CACF,IAAO,EAAS,GAAA,CACR,EAAA,MAAU,EAAc,EAAA,CAAA,qBAE9B,OAAM,EAAmB,EAAY,CACrC,IAAM,MAAO,yDAGX,eAAC,CACC,QAAM,CAAA,QAAU,QAAQ,MAAW,OAAC,OAAe,OAAQ,UAAW,gBAAA,cAAA,YAAA,aAAA,MAAA,CACvE,CACD,IAAI,UAAS,CACX,MAAK,CAAA,EAAM,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACT,MAAS,GACT,OAAO,GACP,KAAG,oBACH,IAAG,aAAK,CACN,MAAM,EAAA,iBAAA,EAAA,MAAA;;;;;;;aAOR,EAAA,MAAA;QACA,EAAA,MAAA,qBAAA,EAAA,MAAA;;;;;;;QAOA,EAAG,MAAO;QACX,EAAM,MAAI;;;;;QAKT,EAAK,MAAK;;;;;;;;;;;;;;;;;;;;;;;QAuBV,EAAI,MAAI;QACR,EAAA,MAAA;QACA,EAAK,MAAM;;;;;;;;;oCASgB,EAAK,MAAI;aACjC,EAAA,MAAY;;;qBAGJ,EAAO,MAAC;YACf,EAAC,MAAM,+DAA+B,EAAA,MAAA;;;;qBAI9C,EAAA,MAAA,qCAAA,EAAA,MAAA;;YAEQ,EAAK,MAAI;;;;QAIb,EAAE,MAAK,0CAAA,EAAA,MAAA;;;;;aAKF,EAAI,MAAI;QACb,EAAI,MAAK;QACT,EAAA,MAAO,8CAAA,EAAA,MAAA;oBACX,EAAA,MAAA;;;;aAIC,EAAA,MAAmB;QACjB,EAAM,MAAM;QACX,EAAI,MAAK;;QAEb,EAAA,MAAA;;YAEQ,EAAC,MAAM;;;;;;;yCAOK,EAAA,6BAAA;;QAEhB,EAAK,MAAM;;;YAGT,EAAM,MAAI;;;;QAIpB,EAAA,MAAA;;;;;;;aAOa,EAAI,MAAI;QACb,EAAI,MAAK;QACT,EAAA,MAAO;;;oBAGK,EAAE,MAAO;;QAExB,EAAA,MAAA;QACG,EAAK,MAAM,iCAAgC,EAAA,MAAA;;qBAExC,EAAA,MAAA;YACL,EAAA,MAAA;;;;;gDAKqB,EAAA,MAAA;qBACV,EAAM,MAAQ,mBAAkB,EAAM,MAAA;;QAEnD,EAAA,MAAA,8BAAA,EAAA,MAAA;;;qCAGO,EAAA,yBAAA;;;6CAGoB,EAAA,iCAAA;0CACW,EAAiB,8BAAA;;;;;;;;;;;;;;;;;;;;;;;QAuBrD,EAAK,MAAA;;;;;;;;;YASA,EAAA,MAAA;;iEAEP,EAAA,MAAA;yBACO,EAAA,MAAyB;YAC9B,EAAA,MAAA,uCAAoB,EAAA,MAAA;;;oCAGA,EAAA,MAAA;YACtB,EAAA,MAAA;;;;;;;0DAOsB,EAAA,MAAA;;;;;;;;oBAQX,EAAA,MAAA;iCACX,EAAA,MAAA;;;;;;;;gBAQA,EAAA,MAAA;;;;;;;;;;;;cAYS,EAAA,MAAW;;;;8BAII,EAAM,MAAM;;;;cAI5B,EAAK,MAAM;;cAEd,EAAA,MAAa,SAAA,EAAA,MAAA;;;;cAIV,EAAW,EAAQ,CAAA,aAAW,EAAQ,MAAA,oCAAA,EAAA,MAAA,kCAAA,EAAA,MAAA;;iBAEjC,EAAA,MAAU,SAAS,EAAK,MAAE,oCAAY,EAAA,MAAA,kCAAA,EAAA,MAAA;OAGhD,CAAC,CAAE,EAAkB,EAAA,EAAA,CAAY,CAAC,EAAmB,EAAU,CAC9D,OAAU,GACV,MAAS,GACT,KAAM,4BACN,YAAK,CAAA;;;;;;;;;;;;;;;;;;;;;0BAsBT,CAAA,CAAA,EAED,CAAC"}
|
|
1
|
+
{"version":3,"file":"fish-shared.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_components_bash_config_command = require('./bash-config-command.cjs');
|
|
3
|
+
const require_components_bash_script_command = require('./bash-script-command.cjs');
|
|
4
|
+
const require_components_bash_shared = require('./bash-shared.cjs');
|
|
5
|
+
const require_components_fish_config_command = require('./fish-config-command.cjs');
|
|
6
|
+
const require_components_fish_script_command = require('./fish-script-command.cjs');
|
|
7
|
+
const require_components_fish_shared = require('./fish-shared.cjs');
|
|
8
|
+
const require_components_powershell_config_command = require('./powershell-config-command.cjs');
|
|
9
|
+
const require_components_powershell_script_command = require('./powershell-script-command.cjs');
|
|
10
|
+
const require_components_powershell_shared = require('./powershell-shared.cjs');
|
|
11
|
+
const require_components_zsh_config_command = require('./zsh-config-command.cjs');
|
|
12
|
+
const require_components_zsh_script_command = require('./zsh-script-command.cjs');
|
|
13
|
+
const require_components_zsh_shared = require('./zsh-shared.cjs');
|
|
14
|
+
|
|
15
|
+
exports.BashCompletionsShared = require_components_bash_shared.BashCompletionsShared;
|
|
16
|
+
exports.BashConfigCompletionsCommand = require_components_bash_config_command.BashConfigCompletionsCommand;
|
|
17
|
+
exports.BashScriptCompletionsCommand = require_components_bash_script_command.BashScriptCompletionsCommand;
|
|
18
|
+
exports.FishCompletionsShared = require_components_fish_shared.FishCompletionsShared;
|
|
19
|
+
exports.FishConfigCompletionsCommand = require_components_fish_config_command.FishConfigCompletionsCommand;
|
|
20
|
+
exports.FishScriptCompletionsCommand = require_components_fish_script_command.FishScriptCompletionsCommand;
|
|
21
|
+
exports.PowerShellCompletionsShared = require_components_powershell_shared.PowerShellCompletionsShared;
|
|
22
|
+
exports.PowerShellConfigCompletionsCommand = require_components_powershell_config_command.PowerShellConfigCompletionsCommand;
|
|
23
|
+
exports.PowerShellScriptCompletionsCommand = require_components_powershell_script_command.PowerShellScriptCompletionsCommand;
|
|
24
|
+
exports.ZshCompletionsShared = require_components_zsh_shared.ZshCompletionsShared;
|
|
25
|
+
exports.ZshConfigCompletionsCommand = require_components_zsh_config_command.ZshConfigCompletionsCommand;
|
|
26
|
+
exports.ZshScriptCompletionsCommand = require_components_zsh_script_command.ZshScriptCompletionsCommand;
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import{BashConfigCompletionsCommand
|
|
1
|
+
import { BashConfigCompletionsCommand } from "./bash-config-command.mjs";
|
|
2
|
+
import { BashScriptCompletionsCommand } from "./bash-script-command.mjs";
|
|
3
|
+
import { BashCompletionsShared } from "./bash-shared.mjs";
|
|
4
|
+
import { FishConfigCompletionsCommand } from "./fish-config-command.mjs";
|
|
5
|
+
import { FishScriptCompletionsCommand } from "./fish-script-command.mjs";
|
|
6
|
+
import { FishCompletionsShared } from "./fish-shared.mjs";
|
|
7
|
+
import { PowerShellConfigCompletionsCommand } from "./powershell-config-command.mjs";
|
|
8
|
+
import { PowerShellScriptCompletionsCommand } from "./powershell-script-command.mjs";
|
|
9
|
+
import { PowerShellCompletionsShared } from "./powershell-shared.mjs";
|
|
10
|
+
import { ZshConfigCompletionsCommand } from "./zsh-config-command.mjs";
|
|
11
|
+
import { ZshScriptCompletionsCommand } from "./zsh-script-command.mjs";
|
|
12
|
+
import { ZshCompletionsShared } from "./zsh-shared.mjs";
|
|
13
|
+
|
|
14
|
+
export { BashCompletionsShared, BashConfigCompletionsCommand, BashScriptCompletionsCommand, FishCompletionsShared, FishConfigCompletionsCommand, FishScriptCompletionsCommand, PowerShellCompletionsShared, PowerShellConfigCompletionsCommand, PowerShellScriptCompletionsCommand, ZshCompletionsShared, ZshConfigCompletionsCommand, ZshScriptCompletionsCommand };
|
|
@@ -1,4 +1,96 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
3
|
+
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
|
+
let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
|
|
7
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
8
|
+
let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
|
|
9
|
+
let _stryke_path = require("@stryke/path");
|
|
10
|
+
|
|
11
|
+
//#region src/components/powershell-config-command.tsx
|
|
12
|
+
function PowerShellConfigCompletionsCommand() {
|
|
13
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
14
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
|
|
15
|
+
get path() {
|
|
16
|
+
return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "powershell", "config", "command.ts");
|
|
17
|
+
},
|
|
18
|
+
imports: {
|
|
19
|
+
"node:os": "os",
|
|
20
|
+
"node:path": ["join"],
|
|
21
|
+
"node:fs/promises": ["readFile", "writeFile"],
|
|
22
|
+
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
23
|
+
},
|
|
24
|
+
builtinImports: { "shell-shock:console": [
|
|
25
|
+
"bold",
|
|
26
|
+
"inlineCode",
|
|
27
|
+
"writeLine",
|
|
28
|
+
"success",
|
|
29
|
+
"warn",
|
|
30
|
+
"help"
|
|
31
|
+
] },
|
|
32
|
+
get children() {
|
|
33
|
+
return [
|
|
34
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, { heading: "Options for the PowerShell Completions - Configuration command." }),
|
|
35
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
36
|
+
"export": true,
|
|
37
|
+
name: "PowerShellConfigCompletionsOptions",
|
|
38
|
+
get children() {
|
|
39
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, {
|
|
40
|
+
heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
|
|
41
|
+
get children() {
|
|
42
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDocDefaultValue, {
|
|
43
|
+
type: "boolean",
|
|
44
|
+
defaultValue: false
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
|
|
48
|
+
name: "display",
|
|
49
|
+
type: "boolean"
|
|
50
|
+
})];
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
54
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, { heading: "Handler logic for the \\`completions powershell config\\` command." }),
|
|
55
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
56
|
+
"export": true,
|
|
57
|
+
"default": true,
|
|
58
|
+
async: true,
|
|
59
|
+
name: "handler",
|
|
60
|
+
parameters: [{
|
|
61
|
+
name: "options",
|
|
62
|
+
type: "PowerShellConfigCompletionsOptions",
|
|
63
|
+
default: "{}"
|
|
64
|
+
}, {
|
|
65
|
+
name: "path",
|
|
66
|
+
type: "string",
|
|
67
|
+
default: `"~/.config/powershell/Microsoft.PowerShell_profile.ps1"`
|
|
68
|
+
}],
|
|
69
|
+
get children() {
|
|
70
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
71
|
+
condition: _alloy_js_core.code`options.display !== true`,
|
|
72
|
+
get children() {
|
|
73
|
+
return [
|
|
74
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
75
|
+
"let": true,
|
|
76
|
+
name: "configPath",
|
|
77
|
+
type: "string",
|
|
78
|
+
initializer: _alloy_js_core.code` path.includes(".") ? path : join(path, "Microsoft.PowerShell_profile.ps1");`
|
|
79
|
+
}),
|
|
80
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
81
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
82
|
+
condition: _alloy_js_core.code`configPath.startsWith("~")`,
|
|
83
|
+
children: _alloy_js_core.code`configPath = join(os.homedir(), configPath.replace("~", "")); `
|
|
84
|
+
}),
|
|
85
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
86
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
87
|
+
"let": true,
|
|
88
|
+
name: "content",
|
|
89
|
+
type: "string",
|
|
90
|
+
initializer: _alloy_js_core.code`"";`
|
|
91
|
+
}),
|
|
92
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
93
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
|
|
2
94
|
content = await readFile(configPath, "utf8");
|
|
3
95
|
} catch (error) {
|
|
4
96
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
@@ -9,15 +101,19 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
|
|
|
9
101
|
}
|
|
10
102
|
}
|
|
11
103
|
|
|
12
|
-
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0,
|
|
104
|
+
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell Completions ###\`);
|
|
13
105
|
|
|
14
|
-
success(\`${(0,
|
|
106
|
+
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} shell completions have been applied to PowerShell configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
110
|
+
return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
15
111
|
writeLine("");
|
|
16
|
-
writeLine(\`### Begin - ${(0,
|
|
112
|
+
writeLine(\`### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell Completions ###\`);
|
|
17
113
|
writeLine("");
|
|
18
114
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
19
115
|
writeLine("");
|
|
20
|
-
writeLine(\`### End - ${(0,
|
|
116
|
+
writeLine(\`### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell Completions ###\`);
|
|
21
117
|
writeLine("");
|
|
22
118
|
writeLine(" ------------------------------------------------- ");
|
|
23
119
|
|
|
@@ -25,4 +121,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
|
|
|
25
121
|
help(\`To enable these completions, perform one of the following actions:
|
|
26
122
|
|
|
27
123
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/powershell/Microsoft.PowerShell_profile.ps1)
|
|
28
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
124
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `;
|
|
125
|
+
} })];
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
exports.PowerShellConfigCompletionsCommand = PowerShellConfigCompletionsCommand;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
|
-
|
|
3
1
|
//#region src/components/powershell-config-command.d.ts
|
|
4
|
-
declare function PowerShellConfigCompletionsCommand():
|
|
2
|
+
declare function PowerShellConfigCompletionsCommand(): import("@alloy-js/core").Children;
|
|
5
3
|
//#endregion
|
|
6
4
|
export { PowerShellConfigCompletionsCommand };
|
|
7
5
|
//# sourceMappingURL=powershell-config-command.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powershell-config-command.d.cts","names":[],"sources":["../../src/components/powershell-config-command.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"powershell-config-command.d.cts","names":[],"sources":["../../src/components/powershell-config-command.tsx"],"mappings":";iBAsCgB,kCAAA,6BAAkC,QAAA"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
|
-
|
|
3
1
|
//#region src/components/powershell-config-command.d.ts
|
|
4
|
-
declare function PowerShellConfigCompletionsCommand():
|
|
2
|
+
declare function PowerShellConfigCompletionsCommand(): import("@alloy-js/core").Children;
|
|
5
3
|
//#endregion
|
|
6
4
|
export { PowerShellConfigCompletionsCommand };
|
|
7
5
|
//# sourceMappingURL=powershell-config-command.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powershell-config-command.d.mts","names":[],"sources":["../../src/components/powershell-config-command.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"powershell-config-command.d.mts","names":[],"sources":["../../src/components/powershell-config-command.tsx"],"mappings":""}
|