powerlines 0.47.124 → 0.47.126
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/bin/bin.mjs +9 -0
- package/bin/build-CJIAgNA5.mjs +1 -0
- package/bin/build.mjs +5 -0
- package/bin/changelog-d-cmenYB.mjs +1 -0
- package/bin/changelog.mjs +527 -0
- package/bin/clean-dutxbMO3.mjs +1 -0
- package/bin/clean.mjs +5 -0
- package/bin/completions-bash-config.mjs +9 -0
- package/bin/completions-bash-script.mjs +9 -0
- package/bin/completions-fish-config.mjs +9 -0
- package/bin/completions-fish-script.mjs +9 -0
- package/bin/completions-powershell-config.mjs +9 -0
- package/bin/completions-powershell-script.mjs +9 -0
- package/bin/completions-zsh-config.mjs +9 -0
- package/bin/completions-zsh-script.mjs +9 -0
- package/bin/config-B0hTZO6E.mjs +1 -0
- package/bin/config-BJFVoVkf.mjs +1 -0
- package/bin/config-BaNVYrnl.mjs +1 -0
- package/bin/config-Bf2LnULJ.mjs +1 -0
- package/bin/create-DYKxyvzg.mjs +1 -0
- package/bin/create-powerlines-DvusHjN3.mjs +1 -0
- package/bin/create.mjs +5 -0
- package/bin/deploy-BMhOgvx4.mjs +1 -0
- package/bin/deploy.mjs +5 -0
- package/bin/docs-CAUeTrLz.mjs +1 -0
- package/bin/docs.mjs +5 -0
- package/bin/gc-DZjHvUuc.mjs +1 -0
- package/bin/gc.mjs +7 -0
- package/bin/help.mjs +5 -0
- package/bin/lint-DdDmoyDN.mjs +1 -0
- package/bin/lint.mjs +5 -0
- package/bin/prepare-Yz_6EWzB.mjs +1 -0
- package/bin/prepare.mjs +5 -0
- package/bin/prompts-BnlPjHFR.mjs +26 -0
- package/bin/script-B97oHT_M.mjs +1 -0
- package/bin/script-Bn4yCHJR.mjs +1 -0
- package/bin/script-DGDOPq0P.mjs +1 -0
- package/bin/script-Di-8LIT0.mjs +1 -0
- package/bin/shared-BiFPKQIb.mjs +235 -0
- package/bin/shared-CLQvIZ7z.mjs +216 -0
- package/bin/shared-ClfTGQiY.mjs +249 -0
- package/bin/shared-D6Uc3liR.mjs +103 -0
- package/bin/types-BhiTsmcq.mjs +1 -0
- package/bin/types.mjs +5 -0
- package/bin/upgrade-aCJAI3aA.mjs +1 -0
- package/bin/upgrade-yP6Jdrm0.mjs +1 -0
- package/bin/upgrade.mjs +5 -0
- package/bin/zsh-Cve0Syog.mjs +3 -0
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import{C as e,S as t,a as n,b as r,c as i,d as a,h as o,j as s,l as c,m as l,p as u,x as d}from"./prompts-BnlPjHFR.mjs";const f=`function __cli_debug
|
|
2
|
+
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
3
|
+
if test -n "$file"
|
|
4
|
+
echo "$argv" >> $file
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
function __cli_perform_completion
|
|
9
|
+
__cli_debug "Starting __cli_perform_completion"
|
|
10
|
+
|
|
11
|
+
# Extract all args except the last one
|
|
12
|
+
set -l args (commandline -opc)
|
|
13
|
+
# Extract the last arg and escape it in case it is a space or wildcard
|
|
14
|
+
set -l lastArg (string escape -- (commandline -ct))
|
|
15
|
+
|
|
16
|
+
__cli_debug "args: $args"
|
|
17
|
+
__cli_debug "last arg: $lastArg"
|
|
18
|
+
|
|
19
|
+
# Build the completion request command
|
|
20
|
+
set -l requestComp "/nix/store/8spcnffxayf4h9v8w075j01bxxgv5c8j-nodejs-slim-26.3.0/bin/node /home/runner/work/powerlines/powerlines/node_modules/.pnpm/nx@22.7.5_@swc-node+register@1.11.1_@swc+core@1.15.40_@swc+helpers@0.5.23__@swc+types@0_559e3db9ab82faa3b71ca2061041f3f6/node_modules/nx/dist/bin/run-executor.js complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
|
|
21
|
+
|
|
22
|
+
__cli_debug "Calling $requestComp"
|
|
23
|
+
set -l results (eval $requestComp 2> /dev/null)
|
|
24
|
+
|
|
25
|
+
# Some programs may output extra empty lines after the directive.
|
|
26
|
+
# Let's ignore them or else it will break completion.
|
|
27
|
+
# Ref: https://github.com/spf13/cobra/issues/1279
|
|
28
|
+
for line in $results[-1..1]
|
|
29
|
+
if test (string trim -- $line) = ""
|
|
30
|
+
# Found an empty line, remove it
|
|
31
|
+
set results $results[1..-2]
|
|
32
|
+
else
|
|
33
|
+
# Found non-empty line, we have our proper output
|
|
34
|
+
break
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
set -l comps $results[1..-2]
|
|
39
|
+
set -l directiveLine $results[-1]
|
|
40
|
+
|
|
41
|
+
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
|
|
42
|
+
# completions must be prefixed with the flag
|
|
43
|
+
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
|
|
44
|
+
|
|
45
|
+
__cli_debug "Comps: $comps"
|
|
46
|
+
__cli_debug "DirectiveLine: $directiveLine"
|
|
47
|
+
__cli_debug "flagPrefix: $flagPrefix"
|
|
48
|
+
|
|
49
|
+
for comp in $comps
|
|
50
|
+
printf "%s%s
|
|
51
|
+
" "$flagPrefix" "$comp"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
printf "%s
|
|
55
|
+
" "$directiveLine"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# This function limits calls to __cli_perform_completion, by caching the result
|
|
59
|
+
function __cli_perform_completion_once
|
|
60
|
+
__cli_debug "Starting __cli_perform_completion_once"
|
|
61
|
+
|
|
62
|
+
if test -n "$__cli_perform_completion_once_result"
|
|
63
|
+
__cli_debug "Seems like a valid result already exists, skipping __cli_perform_completion"
|
|
64
|
+
return 0
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
set --global __cli_perform_completion_once_result (__cli_perform_completion)
|
|
68
|
+
if test -z "$__cli_perform_completion_once_result"
|
|
69
|
+
__cli_debug "No completions, probably due to a failure"
|
|
70
|
+
return 1
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
__cli_debug "Performed completions and set __cli_perform_completion_once_result"
|
|
74
|
+
return 0
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# This function is used to clear the cached result after completions are run
|
|
78
|
+
function __cli_clear_perform_completion_once_result
|
|
79
|
+
__cli_debug ""
|
|
80
|
+
__cli_debug "========= clearing previously set __cli_perform_completion_once_result variable =========="
|
|
81
|
+
set --erase __cli_perform_completion_once_result
|
|
82
|
+
__cli_debug "Successfully erased the variable __cli_perform_completion_once_result"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
function __cli_requires_order_preservation
|
|
86
|
+
__cli_debug ""
|
|
87
|
+
__cli_debug "========= checking if order preservation is required =========="
|
|
88
|
+
|
|
89
|
+
__cli_perform_completion_once
|
|
90
|
+
if test -z "$__cli_perform_completion_once_result"
|
|
91
|
+
__cli_debug "Error determining if order preservation is required"
|
|
92
|
+
return 1
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
set -l directive (string sub --start 2 $__cli_perform_completion_once_result[-1])
|
|
96
|
+
__cli_debug "Directive is: $directive"
|
|
97
|
+
|
|
98
|
+
set -l shellCompDirectiveKeepOrder 32
|
|
99
|
+
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
|
|
100
|
+
__cli_debug "Keeporder is: $keeporder"
|
|
101
|
+
|
|
102
|
+
if test $keeporder -ne 0
|
|
103
|
+
__cli_debug "This does require order preservation"
|
|
104
|
+
return 0
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
__cli_debug "This doesn't require order preservation"
|
|
108
|
+
return 1
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# This function does two things:
|
|
112
|
+
# - Obtain the completions and store them in the global __cli_comp_results
|
|
113
|
+
# - Return false if file completion should be performed
|
|
114
|
+
function __cli_prepare_completions
|
|
115
|
+
__cli_debug ""
|
|
116
|
+
__cli_debug "========= starting completion logic =========="
|
|
117
|
+
|
|
118
|
+
# Start fresh
|
|
119
|
+
set --erase __cli_comp_results
|
|
120
|
+
|
|
121
|
+
__cli_perform_completion_once
|
|
122
|
+
__cli_debug "Completion results: $__cli_perform_completion_once_result"
|
|
123
|
+
|
|
124
|
+
if test -z "$__cli_perform_completion_once_result"
|
|
125
|
+
__cli_debug "No completion, probably due to a failure"
|
|
126
|
+
# Might as well do file completion, in case it helps
|
|
127
|
+
return 1
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
set -l directive (string sub --start 2 $__cli_perform_completion_once_result[-1])
|
|
131
|
+
set --global __cli_comp_results $__cli_perform_completion_once_result[1..-2]
|
|
132
|
+
|
|
133
|
+
__cli_debug "Completions are: $__cli_comp_results"
|
|
134
|
+
__cli_debug "Directive is: $directive"
|
|
135
|
+
|
|
136
|
+
set -l shellCompDirectiveError 1
|
|
137
|
+
set -l shellCompDirectiveNoSpace 2
|
|
138
|
+
set -l shellCompDirectiveNoFileComp 4
|
|
139
|
+
set -l shellCompDirectiveFilterFileExt 8
|
|
140
|
+
set -l shellCompDirectiveFilterDirs 16
|
|
141
|
+
if test -z "$directive"
|
|
142
|
+
set directive 0
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
|
|
146
|
+
if test $compErr -eq 1
|
|
147
|
+
__cli_debug "Received error directive: aborting."
|
|
148
|
+
# Might as well do file completion, in case it helps
|
|
149
|
+
return 1
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
|
|
153
|
+
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
|
|
154
|
+
if test $filefilter -eq 1; or test $dirfilter -eq 1
|
|
155
|
+
__cli_debug "File extension filtering or directory filtering not supported"
|
|
156
|
+
# Do full file completion instead
|
|
157
|
+
return 1
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
|
|
161
|
+
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
|
|
162
|
+
|
|
163
|
+
__cli_debug "nospace: $nospace, nofiles: $nofiles"
|
|
164
|
+
|
|
165
|
+
# If we want to prevent a space, or if file completion is NOT disabled,
|
|
166
|
+
# we need to count the number of valid completions.
|
|
167
|
+
# To do so, we will filter on prefix as the completions we have received
|
|
168
|
+
# may not already be filtered so as to allow fish to match on different
|
|
169
|
+
# criteria than the prefix.
|
|
170
|
+
if test $nospace -ne 0; or test $nofiles -eq 0
|
|
171
|
+
set -l prefix (commandline -t | string escape --style=regex)
|
|
172
|
+
__cli_debug "prefix: $prefix"
|
|
173
|
+
|
|
174
|
+
set -l completions (string match -r -- "^$prefix.*" $__cli_comp_results)
|
|
175
|
+
set --global __cli_comp_results $completions
|
|
176
|
+
__cli_debug "Filtered completions are: $__cli_comp_results"
|
|
177
|
+
|
|
178
|
+
# Important not to quote the variable for count to work
|
|
179
|
+
set -l numComps (count $__cli_comp_results)
|
|
180
|
+
__cli_debug "numComps: $numComps"
|
|
181
|
+
|
|
182
|
+
if test $numComps -eq 1; and test $nospace -ne 0
|
|
183
|
+
# We must first split on to get rid of the descriptions to be
|
|
184
|
+
# able to check what the actual completion will be.
|
|
185
|
+
# We don't need descriptions anyway since there is only a single
|
|
186
|
+
# real completion which the shell will expand immediately.
|
|
187
|
+
set -l split (string split --max 1 " " $__cli_comp_results[1])
|
|
188
|
+
|
|
189
|
+
# Fish won't add a space if the completion ends with any
|
|
190
|
+
# of the following characters: @=/:.,
|
|
191
|
+
set -l lastChar (string sub -s -1 -- $split)
|
|
192
|
+
if not string match -r -q "[@=/:.,]" -- "$lastChar"
|
|
193
|
+
# In other cases, to support the "nospace" directive we trick the shell
|
|
194
|
+
# by outputting an extra, longer completion.
|
|
195
|
+
__cli_debug "Adding second completion to perform nospace directive"
|
|
196
|
+
set --global __cli_comp_results $split[1] $split[1].
|
|
197
|
+
__cli_debug "Completions are now: $__cli_comp_results"
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
if test $numComps -eq 0; and test $nofiles -eq 0
|
|
202
|
+
# To be consistent with bash and zsh, we only trigger file
|
|
203
|
+
# completion when there are no other completions
|
|
204
|
+
__cli_debug "Requesting file completion"
|
|
205
|
+
return 1
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
return 0
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
|
|
213
|
+
# so we can properly delete any completions provided by another script.
|
|
214
|
+
# Only do this if the program can be found, or else fish may print some errors; besides,
|
|
215
|
+
# the existing completions will only be loaded if the program can be found.
|
|
216
|
+
if type -q "cli"
|
|
217
|
+
# The space after the program name is essential to trigger completion for the program
|
|
218
|
+
# and not completion of the program name itself.
|
|
219
|
+
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
|
|
220
|
+
complete --do-complete "cli " > /dev/null 2>&1
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Remove any pre-existing completions for the program since we will be handling all of them.
|
|
224
|
+
complete -c cli -e
|
|
225
|
+
# This will get called after the two calls below and clear the cached result
|
|
226
|
+
complete -c cli -n '__cli_clear_perform_completion_once_result'
|
|
227
|
+
# The call to __cli_prepare_completions will setup __cli_comp_results
|
|
228
|
+
# which provides the program's completion choices.
|
|
229
|
+
# If this doesn't require order preservation, we don't use the -k flag
|
|
230
|
+
complete -c cli -n 'not __cli_requires_order_preservation && __cli_prepare_completions' -f -a '$__cli_comp_results'
|
|
231
|
+
# Otherwise we use the -k flag
|
|
232
|
+
complete -k -c cli -n '__cli_requires_order_preservation && __cli_prepare_completions' -f -a '$__cli_comp_results'
|
|
233
|
+
`,p=f.split(`
|
|
234
|
+
`).map(f=>f.trim()?f.trim().startsWith(`#`)?`${a(f)}`:s(f).replaceAll(/(?<=\$(\{|\()).*(?=(\}\)))/g,l(`$&`)).replaceAll(/(\"|\').*(\"|\')/g,i(`$&`)).replaceAll(/(\[|\]|\(|\)|\||<|>|\$\(|\$?\{|\}|\+|=|;|:)/g,n(u(`$&`))).replaceAll(/(function|complete)\s+/g,l(`$&`)).replaceAll(/(?<=(function|complete)\s+)\w/g,n(o(`$&`))).replaceAll(/set\s+/g,t(`$&`)).replaceAll(/(?<=set\s+)\w/g,n(e(`$&`))).replaceAll(/while\s+/g,i(`$&`)).replaceAll(/(?<=while\s+)\w/g,n(c(`$&`))).replaceAll(/(if|fi|else|elif|then|done)\s+/g,l(`$&`)).replaceAll(/\s__\w/g,n(d(`$&`))).replaceAll(/(?<=\s)(-\w|--\w[\w-]*)(?=\s|$)/g,n(r(`$&`))):``).join(`
|
|
235
|
+
`);export{p as n,f as t};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import{C as e,S as t,a as n,b as r,c as i,d as a,h as o,j as s,l as c,m as l,p as u,x as d}from"./prompts-BnlPjHFR.mjs";const f=`__cli_debug() {
|
|
2
|
+
local file="$BASH_COMP_DEBUG_FILE"
|
|
3
|
+
if [[ -n \${file} ]]; then
|
|
4
|
+
echo "$*" >> "\${file}"
|
|
5
|
+
fi
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
_cli() {
|
|
9
|
+
local shellCompDirectiveError=1
|
|
10
|
+
local shellCompDirectiveNoSpace=2
|
|
11
|
+
local shellCompDirectiveNoFileComp=4
|
|
12
|
+
local shellCompDirectiveFilterFileExt=8
|
|
13
|
+
local shellCompDirectiveFilterDirs=16
|
|
14
|
+
local shellCompDirectiveKeepOrder=32
|
|
15
|
+
|
|
16
|
+
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
|
17
|
+
local -a completions
|
|
18
|
+
|
|
19
|
+
__cli_debug "
|
|
20
|
+
========= starting completion logic =========="
|
|
21
|
+
__cli_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
|
|
22
|
+
|
|
23
|
+
# The user could have moved the cursor backwards on the command-line.
|
|
24
|
+
# We need to trigger completion from the $CURRENT location, so we need
|
|
25
|
+
# to truncate the command-line ($words) up to the $CURRENT location.
|
|
26
|
+
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
|
|
27
|
+
words=( "\${=words[1,CURRENT]}" )
|
|
28
|
+
__cli_debug "Truncated words[*]: \${words[*]},"
|
|
29
|
+
|
|
30
|
+
lastParam=\${words[-1]}
|
|
31
|
+
lastChar=\${lastParam[-1]}
|
|
32
|
+
__cli_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
|
|
33
|
+
# For zsh, when completing a flag with an = (e.g., cli -n=<TAB>)
|
|
34
|
+
# completions must be prefixed with the flag
|
|
35
|
+
setopt local_options BASH_REMATCH
|
|
36
|
+
if [[ "\${lastParam}" =~ '-.*=' ]]; then
|
|
37
|
+
# We are dealing with a flag with an =
|
|
38
|
+
flagPrefix="-P \${BASH_REMATCH}"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Prepare the command to obtain completions, ensuring arguments are quoted for eval
|
|
42
|
+
local -a args_to_quote=("\${(@)words[2,-1]}")
|
|
43
|
+
if [ "\${lastChar}" = "" ]; then
|
|
44
|
+
# If the last parameter is complete (there is a space following it)
|
|
45
|
+
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
46
|
+
__cli_debug "Adding extra empty parameter"
|
|
47
|
+
args_to_quote+=("")
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
# Use Zsh's (q) flag to quote each argument safely for eval
|
|
51
|
+
local quoted_args=("\${(@q)args_to_quote}")
|
|
52
|
+
|
|
53
|
+
# Join the main command and the quoted arguments into a single string for eval
|
|
54
|
+
requestComp="/nix/store/8spcnffxayf4h9v8w075j01bxxgv5c8j-nodejs-slim-26.3.0/bin/node /home/runner/work/powerlines/powerlines/node_modules/.pnpm/nx@22.7.5_@swc-node+register@1.11.1_@swc+core@1.15.40_@swc+helpers@0.5.23__@swc+types@0_559e3db9ab82faa3b71ca2061041f3f6/node_modules/nx/dist/bin/run-executor.js complete -- \${quoted_args[*]}"
|
|
55
|
+
|
|
56
|
+
__cli_debug "About to call: eval \${requestComp}"
|
|
57
|
+
|
|
58
|
+
# Use eval to handle any environment variables and such
|
|
59
|
+
out=$(eval \${requestComp} 2>/dev/null)
|
|
60
|
+
__cli_debug "completion output: \${out}"
|
|
61
|
+
|
|
62
|
+
# Extract the directive integer following a : from the last line
|
|
63
|
+
local lastLine
|
|
64
|
+
while IFS='
|
|
65
|
+
' read -r line; do
|
|
66
|
+
lastLine=\${line}
|
|
67
|
+
done < <(printf "%s
|
|
68
|
+
" "\${out[@]}")
|
|
69
|
+
__cli_debug "last line: \${lastLine}"
|
|
70
|
+
|
|
71
|
+
if [ "\${lastLine[1]}" = : ]; then
|
|
72
|
+
directive=\${lastLine[2,-1]}
|
|
73
|
+
# Remove the directive including the : and the newline
|
|
74
|
+
local suffix
|
|
75
|
+
(( suffix=\${#lastLine}+2))
|
|
76
|
+
out=\${out[1,-$suffix]}
|
|
77
|
+
else
|
|
78
|
+
# There is no directive specified. Leave $out as is.
|
|
79
|
+
__cli_debug "No directive found. Setting to default"
|
|
80
|
+
directive=0
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
__cli_debug "directive: \${directive}"
|
|
84
|
+
__cli_debug "completions: \${out}"
|
|
85
|
+
__cli_debug "flagPrefix: \${flagPrefix}"
|
|
86
|
+
|
|
87
|
+
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
|
88
|
+
__cli_debug "Completion received error. Ignoring completions."
|
|
89
|
+
return
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
local activeHelpMarker="%"
|
|
93
|
+
local endIndex=\${#activeHelpMarker}
|
|
94
|
+
local startIndex=$((\${#activeHelpMarker}+1))
|
|
95
|
+
local hasActiveHelp=0
|
|
96
|
+
while IFS='
|
|
97
|
+
' read -r comp; do
|
|
98
|
+
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
99
|
+
if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
100
|
+
__cli_debug "ActiveHelp found: $comp"
|
|
101
|
+
comp="\${comp[$startIndex,-1]}"
|
|
102
|
+
if [ -n "$comp" ]; then
|
|
103
|
+
compadd -x "\${comp}"
|
|
104
|
+
__cli_debug "ActiveHelp will need delimiter"
|
|
105
|
+
hasActiveHelp=1
|
|
106
|
+
fi
|
|
107
|
+
continue
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
if [ -n "$comp" ]; then
|
|
111
|
+
# If requested, completions are returned with a description.
|
|
112
|
+
# The description is preceded by a TAB character.
|
|
113
|
+
# For zsh's _describe, we need to use a : instead of a TAB.
|
|
114
|
+
# We first need to escape any : as part of the completion itself.
|
|
115
|
+
comp=\${comp//:/:}
|
|
116
|
+
|
|
117
|
+
local tab="$(printf ' ')"
|
|
118
|
+
comp=\${comp//$tab/:}
|
|
119
|
+
|
|
120
|
+
__cli_debug "Adding completion: \${comp}"
|
|
121
|
+
completions+=\${comp}
|
|
122
|
+
lastComp=$comp
|
|
123
|
+
fi
|
|
124
|
+
done < <(printf "%s
|
|
125
|
+
" "\${out[@]}")
|
|
126
|
+
|
|
127
|
+
# Add a delimiter after the activeHelp statements, but only if:
|
|
128
|
+
# - there are completions following the activeHelp statements, or
|
|
129
|
+
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
130
|
+
if [ $hasActiveHelp -eq 1 ]; then
|
|
131
|
+
if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
132
|
+
__cli_debug "Adding activeHelp delimiter"
|
|
133
|
+
compadd -x "--"
|
|
134
|
+
hasActiveHelp=0
|
|
135
|
+
fi
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
|
139
|
+
__cli_debug "Activating nospace."
|
|
140
|
+
noSpace="-S ''"
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
144
|
+
__cli_debug "Activating keep order."
|
|
145
|
+
keepOrder="-V"
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
|
149
|
+
# File extension filtering
|
|
150
|
+
local filteringCmd
|
|
151
|
+
filteringCmd='_files'
|
|
152
|
+
for filter in \${completions[@]}; do
|
|
153
|
+
if [ \${filter[1]} != '*' ]; then
|
|
154
|
+
# zsh requires a glob pattern to do file filtering
|
|
155
|
+
filter="*.$filter"
|
|
156
|
+
fi
|
|
157
|
+
filteringCmd+=" -g $filter"
|
|
158
|
+
done
|
|
159
|
+
filteringCmd+=" \${flagPrefix}"
|
|
160
|
+
|
|
161
|
+
__cli_debug "File filtering command: $filteringCmd"
|
|
162
|
+
_arguments '*:filename:'"$filteringCmd"
|
|
163
|
+
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
|
164
|
+
# File completion for directories only
|
|
165
|
+
local subdir
|
|
166
|
+
subdir="\${completions[1]}"
|
|
167
|
+
if [ -n "$subdir" ]; then
|
|
168
|
+
__cli_debug "Listing directories in $subdir"
|
|
169
|
+
pushd "\${subdir}" >/dev/null 2>&1
|
|
170
|
+
else
|
|
171
|
+
__cli_debug "Listing directories in ."
|
|
172
|
+
fi
|
|
173
|
+
|
|
174
|
+
local result
|
|
175
|
+
_arguments '*:dirname:_files -/'" \${flagPrefix}"
|
|
176
|
+
result=$?
|
|
177
|
+
if [ -n "$subdir" ]; then
|
|
178
|
+
popd >/dev/null 2>&1
|
|
179
|
+
fi
|
|
180
|
+
return $result
|
|
181
|
+
else
|
|
182
|
+
__cli_debug "Calling _describe"
|
|
183
|
+
if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
|
|
184
|
+
__cli_debug "_describe found some completions"
|
|
185
|
+
|
|
186
|
+
# Return the success of having called _describe
|
|
187
|
+
return 0
|
|
188
|
+
else
|
|
189
|
+
__cli_debug "_describe did not find completions."
|
|
190
|
+
__cli_debug "Checking if we should do file completion."
|
|
191
|
+
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
|
192
|
+
__cli_debug "deactivating file completion"
|
|
193
|
+
|
|
194
|
+
# Return 0 to indicate completion is finished and prevent zsh from
|
|
195
|
+
# trying other completion algorithms (which could cause hanging).
|
|
196
|
+
# We use NoFileComp directive to explicitly disable file completion.
|
|
197
|
+
return 0
|
|
198
|
+
else
|
|
199
|
+
# Perform file completion
|
|
200
|
+
__cli_debug "Activating file completion"
|
|
201
|
+
|
|
202
|
+
# We must return the result of this command, so it must be the
|
|
203
|
+
# last command, or else we must store its result to return it.
|
|
204
|
+
_arguments '*:filename:_files'" \${flagPrefix}"
|
|
205
|
+
fi
|
|
206
|
+
fi
|
|
207
|
+
fi
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
# don't run the completion function when being sourced or eval-ed
|
|
211
|
+
if [ "\${funcstack[1]}" = "_cli" ]; then
|
|
212
|
+
_cli
|
|
213
|
+
fi
|
|
214
|
+
`,p=f.split(`
|
|
215
|
+
`).map(f=>f.trim()?f.trim().startsWith(`#`)?`${a(f)}`:s(f).replaceAll(/(?<=\$(\{|\()).*(?=(\}\)))/g,l(`$&`)).replaceAll(/\".*\"/g,i(`$&`)).replaceAll(/(\[|\]|\(|\)|\||<|>|\$\(|\$?\{|\}|\+|=|;|:)/g,n(u(`$&`))).replaceAll(/(readonly|complete)\s+/g,l(`$&`)).replaceAll(/(?<=(readonly|complete)\s+)\w/g,n(o(`$&`))).replaceAll(/local\s+/g,t(`$&`)).replaceAll(/(?<=local\s+)\w/g,n(e(`$&`))).replaceAll(/(for|while)\s+/g,i(`$&`)).replaceAll(/(?<=for|while\s+)\w/g,n(c(`$&`))).replaceAll(/(return|if|fi|else|elif|then|done)\s+/g,l(`$&`)).replaceAll(/__\w/g,n(d(`$&`))).replaceAll(/(?<=\s)(-\w|--\w[\w-]*)(?=\s|$)/g,n(r(`$&`))):``).join(`
|
|
216
|
+
`);export{p as n,f as t};
|