@wirecat/drive-cli 0.44.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/dist/bin/drive.js +35 -40
  2. package/dist/bundle/all-profiles-LTHNCWQW.js +26 -0
  3. package/dist/bundle/anthropic-NOJEF3V2.js +71 -0
  4. package/dist/bundle/bun-ADJVI4HY.js +169 -0
  5. package/dist/bundle/bun-sqlite-GNXLBF2A.js +70 -0
  6. package/dist/bundle/chunk-2FTZBZOB.js +2315 -0
  7. package/dist/bundle/chunk-2YU3CXFD.js +3391 -0
  8. package/dist/bundle/chunk-35GRI4DI.js +375 -0
  9. package/dist/bundle/chunk-37MAA6F2.js +5624 -0
  10. package/dist/bundle/chunk-3V6NPZY7.js +2352 -0
  11. package/dist/bundle/chunk-4TIC23D2.js +9 -0
  12. package/dist/bundle/chunk-4TQSNQVV.js +1071 -0
  13. package/dist/bundle/chunk-4UE7AVHZ.js +150 -0
  14. package/dist/bundle/chunk-5DPV7X27.js +663 -0
  15. package/dist/bundle/chunk-5FONRUG6.js +24805 -0
  16. package/dist/bundle/chunk-5ZVLM6YR.js +19 -0
  17. package/dist/bundle/chunk-64WJYT2F.js +3954 -0
  18. package/dist/bundle/chunk-65GGKAQ7.js +82 -0
  19. package/dist/bundle/chunk-66N2DGGC.js +515 -0
  20. package/dist/bundle/chunk-6KFA6HOM.js +2941 -0
  21. package/dist/bundle/chunk-6Y2BYFXQ.js +65 -0
  22. package/dist/bundle/chunk-7NCG2SHR.js +74 -0
  23. package/dist/bundle/chunk-7PVNJAQ2.js +73 -0
  24. package/dist/bundle/chunk-7XWUOCGW.js +190 -0
  25. package/dist/bundle/chunk-A6ZKTNTZ.js +168 -0
  26. package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
  27. package/dist/bundle/chunk-AH3SNVCV.js +498 -0
  28. package/dist/bundle/chunk-AN3GVZTU.js +76 -0
  29. package/dist/bundle/chunk-BPBIBVFH.js +166 -0
  30. package/dist/bundle/chunk-C4XP5T73.js +264 -0
  31. package/dist/bundle/chunk-C6SMAEED.js +18102 -0
  32. package/dist/bundle/chunk-CDI67JSB.js +1092 -0
  33. package/dist/bundle/chunk-CEO5HPRL.js +25 -0
  34. package/dist/bundle/chunk-CFT7UHF6.js +15572 -0
  35. package/dist/bundle/chunk-DC4T3FNP.js +1913 -0
  36. package/dist/bundle/chunk-DCTXOMOR.js +35 -0
  37. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  38. package/dist/bundle/chunk-EVWXODYV.js +754 -0
  39. package/dist/bundle/chunk-GKHM6I64.js +2356 -0
  40. package/dist/bundle/chunk-GNI7INK6.js +18 -0
  41. package/dist/bundle/chunk-GTYY6BIE.js +58 -0
  42. package/dist/bundle/chunk-GX4WEMAG.js +164 -0
  43. package/dist/bundle/chunk-HA3WCVGY.js +8179 -0
  44. package/dist/bundle/chunk-HLONHTSG.js +281 -0
  45. package/dist/bundle/chunk-HOIUIKWS.js +236 -0
  46. package/dist/bundle/chunk-HTQTIKWP.js +928 -0
  47. package/dist/bundle/chunk-I5EJHKNC.js +111 -0
  48. package/dist/bundle/chunk-ICKNJIGE.js +31 -0
  49. package/dist/bundle/chunk-IGB5CJCA.js +62 -0
  50. package/dist/bundle/chunk-IP4OK7RQ.js +24 -0
  51. package/dist/bundle/chunk-IVQ6342B.js +2 -0
  52. package/dist/bundle/chunk-K4N2DKE5.js +17 -0
  53. package/dist/bundle/chunk-LNB7BIZL.js +844 -0
  54. package/dist/bundle/chunk-LVDHWNJF.js +193 -0
  55. package/dist/bundle/chunk-LW2G4U6W.js +570 -0
  56. package/dist/bundle/chunk-LWT55XC5.js +60 -0
  57. package/dist/bundle/chunk-LY26NW3I.js +6848 -0
  58. package/dist/bundle/chunk-MJR2OTO4.js +1714 -0
  59. package/dist/bundle/chunk-MWUITL6N.js +42 -0
  60. package/dist/bundle/chunk-N47CYWEM.js +454 -0
  61. package/dist/bundle/chunk-NKZ6V4JW.js +263 -0
  62. package/dist/bundle/chunk-NQ6LLDDC.js +161 -0
  63. package/dist/bundle/chunk-NZIHPYY5.js +215 -0
  64. package/dist/bundle/chunk-OECPFZLP.js +3541 -0
  65. package/dist/bundle/chunk-P5KGFT7U.js +18 -0
  66. package/dist/bundle/chunk-PDH2QQQV.js +484 -0
  67. package/dist/bundle/chunk-PIN5RZ3D.js +63 -0
  68. package/dist/bundle/chunk-PJDO7AFZ.js +421 -0
  69. package/dist/bundle/chunk-PWKXHDBQ.js +18078 -0
  70. package/dist/bundle/chunk-QLZGLPJL.js +100 -0
  71. package/dist/bundle/chunk-SBZB7HMU.js +1055 -0
  72. package/dist/bundle/chunk-SGOPYPVW.js +835 -0
  73. package/dist/bundle/chunk-TDC6JGDA.js +630 -0
  74. package/dist/bundle/chunk-TOYPN2XX.js +288 -0
  75. package/dist/bundle/chunk-UC44ZMQV.js +78 -0
  76. package/dist/bundle/chunk-V7GN5BI7.js +99 -0
  77. package/dist/bundle/chunk-VO4KOLQZ.js +119 -0
  78. package/dist/bundle/chunk-WPGCDWPU.js +1855 -0
  79. package/dist/bundle/chunk-WQMVSQPP.js +886 -0
  80. package/dist/bundle/chunk-WZUJKUBK.js +384 -0
  81. package/dist/bundle/chunk-X5DFDGWS.js +2 -0
  82. package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
  83. package/dist/bundle/chunk-XPEWOPJR.js +431 -0
  84. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  85. package/dist/bundle/chunk-Y5EJSZXV.js +220 -0
  86. package/dist/bundle/chunk-YE3J6DLY.js +106 -0
  87. package/dist/bundle/chunk-YFLKH3NZ.js +48 -0
  88. package/dist/bundle/chunk-YJX4X564.js +138 -0
  89. package/dist/bundle/chunk-YJZBJ2TM.js +71 -0
  90. package/dist/bundle/chunk-Z4O6C7WR.js +1973 -0
  91. package/dist/bundle/chunk-ZIHLE7LG.js +15992 -0
  92. package/dist/bundle/chunk-ZPMLLONT.js +1054 -0
  93. package/dist/bundle/chunk-ZQNXKWUY.js +35584 -0
  94. package/dist/bundle/chunk-ZS635F4O.js +45 -0
  95. package/dist/bundle/chunk-ZU732VCC.js +122 -0
  96. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  97. package/dist/bundle/command-contract-HX35D7KV.js +38 -0
  98. package/dist/bundle/dist-MWTMOYWT.js +7577 -0
  99. package/dist/bundle/dist-PY3MVR3G.js +21 -0
  100. package/dist/bundle/drive.js +50 -0
  101. package/dist/bundle/echarts-RFTK737T.js +42501 -0
  102. package/dist/bundle/embed-5NAGJUMD.js +37 -0
  103. package/dist/bundle/embedder-EWXLIGBY.js +110 -0
  104. package/dist/bundle/entry-YCPJ6H6U.js +15 -0
  105. package/dist/bundle/failure-XBWHHBEW.js +37 -0
  106. package/dist/bundle/first-run-LNAZDBB4.js +24 -0
  107. package/dist/bundle/first-screen-P5NNFJD7.js +36 -0
  108. package/dist/bundle/google-5FFKRHHC.js +32 -0
  109. package/dist/bundle/google-api-TJCFOOAP.js +82 -0
  110. package/dist/bundle/identity-53ZMPL2O.js +10 -0
  111. package/dist/bundle/instructions-FHNL7CMW.js +9 -0
  112. package/dist/bundle/login-VXXZZR6G.js +158 -0
  113. package/dist/bundle/mcp-2CJCJXSW.js +95 -0
  114. package/dist/bundle/mcp-F4XZO76F.js +507 -0
  115. package/dist/bundle/mcp-IXFC2VVR.js +165 -0
  116. package/dist/bundle/mdast-util-from-markdown-FXEPSNER.js +1958 -0
  117. package/dist/bundle/mdast-util-gfm-SZM5GBDF.js +2103 -0
  118. package/dist/bundle/micromark-extension-gfm-GRL24TU6.js +1838 -0
  119. package/dist/bundle/node-P4E63KXA.js +2340 -0
  120. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  121. package/dist/bundle/node-ZMCACJVS.js +176 -0
  122. package/dist/bundle/node-sqlite-QJQ5S7KS.js +46 -0
  123. package/dist/bundle/oauth-TZFDPAFE.js +18 -0
  124. package/dist/bundle/open-IYM25QTL.js +20 -0
  125. package/dist/bundle/process-ZPTLNVQS.js +91 -0
  126. package/dist/bundle/program-YX7DZMPR.js +24100 -0
  127. package/dist/bundle/prompt-TGWTVIEK.js +13 -0
  128. package/dist/bundle/reasons-Q5LOQESQ.js +11 -0
  129. package/dist/bundle/recognize-AGPMWKIY.js +191 -0
  130. package/dist/bundle/remote-QV7QSLAK.js +28 -0
  131. package/dist/bundle/rerank-HZKJJCS4.js +51 -0
  132. package/dist/bundle/serve-NRJQOVT4.js +20 -0
  133. package/dist/bundle/server-2UQDEWTS.js +818 -0
  134. package/dist/bundle/server-R4JUHFSW.js +56 -0
  135. package/dist/bundle/services-NZQWVMOE.js +333 -0
  136. package/dist/bundle/sqlite-runtime-6MXHTYYU.js +17 -0
  137. package/dist/bundle/state-IF2FLTSY.js +34 -0
  138. package/dist/bundle/store-HBD54IRL.js +142 -0
  139. package/dist/bundle/store-HVIBXOXS.js +125 -0
  140. package/dist/bundle/store-maintenance-command-U3F4RGJB.js +57 -0
  141. package/dist/bundle/terminal-TFCTWLOS.js +11 -0
  142. package/dist/bundle/tokens-5D5YUA2Q.js +103 -0
  143. package/dist/commands/mcp.d.ts.map +1 -1
  144. package/dist/commands/mcp.js +87 -37
  145. package/dist/commands/mcp.js.map +1 -1
  146. package/dist/contract-overrides.d.ts.map +1 -1
  147. package/dist/contract-overrides.js +78 -53
  148. package/dist/contract-overrides.js.map +1 -1
  149. package/dist/mcp.d.ts +13 -5
  150. package/dist/mcp.d.ts.map +1 -1
  151. package/dist/mcp.js +20 -10
  152. package/dist/mcp.js.map +1 -1
  153. package/dist/program.js +4 -4
  154. package/dist/program.js.map +1 -1
  155. package/dist/registry.d.ts +2 -2
  156. package/dist/registry.d.ts.map +1 -1
  157. package/dist/registry.js +3 -3
  158. package/dist/registry.js.map +1 -1
  159. package/dist/state.d.ts +5 -2
  160. package/dist/state.d.ts.map +1 -1
  161. package/dist/state.js +5 -2
  162. package/dist/state.js.map +1 -1
  163. package/dist/version.d.ts +1 -1
  164. package/dist/version.js +1 -1
  165. package/package.json +7 -5
  166. package/skills/drive-cli/SKILL.md +1 -0
@@ -0,0 +1,1055 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ __name
5
+ } from "./chunk-ZVVMGPBJ.js";
6
+
7
+ // node_modules/.pnpm/@bomb.sh+tab@0.0.22_commander@15.0.0/node_modules/@bomb.sh/tab/dist/powershell-C1q3FW2e.mjs
8
+ function t(t2, n2) {
9
+ return `#compdef ${t2}
10
+ compdef _${t2} ${t2}
11
+
12
+ # zsh completion for ${t2} -*- shell-script -*-
13
+
14
+ __${t2}_debug() {
15
+ local file="$BASH_COMP_DEBUG_FILE"
16
+ if [[ -n \${file} ]]; then
17
+ echo "$*" >> "\${file}"
18
+ fi
19
+ }
20
+
21
+ _${t2}() {
22
+ local shellCompDirectiveError=${a.ShellCompDirectiveError}
23
+ local shellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
24
+ local shellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
25
+ local shellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
26
+ local shellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
27
+ local shellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
28
+
29
+ local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
30
+ local -a completions
31
+
32
+ __${t2}_debug "\\n========= starting completion logic =========="
33
+ __${t2}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
34
+
35
+ # The user could have moved the cursor backwards on the command-line.
36
+ # We need to trigger completion from the $CURRENT location, so we need
37
+ # to truncate the command-line ($words) up to the $CURRENT location.
38
+ # (We cannot use $CURSOR as its value does not work when a command is an alias.)
39
+ words=( "\${=words[1,CURRENT]}" )
40
+ __${t2}_debug "Truncated words[*]: \${words[*]},"
41
+
42
+ lastParam=\${words[-1]}
43
+ lastChar=\${lastParam[-1]}
44
+ __${t2}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
45
+
46
+ # For zsh, when completing a flag with an = (e.g., ${t2} -n=<TAB>)
47
+ # completions must be prefixed with the flag
48
+ setopt local_options BASH_REMATCH
49
+ if [[ "\${lastParam}" =~ '-.*=' ]]; then
50
+ # We are dealing with a flag with an =
51
+ flagPrefix="-P \${BASH_REMATCH}"
52
+ fi
53
+
54
+ # Prepare the command to obtain completions, ensuring arguments are quoted for eval
55
+ local -a args_to_quote=("\${(@)words[2,-1]}")
56
+ if [ "\${lastChar}" = "" ] && [ "\${args_to_quote[-1]}" != "" ]; then
57
+ # If the last parameter is complete (there is a space following it)
58
+ # We add an extra empty parameter so we can indicate this to the go completion code.
59
+ __${t2}_debug "Adding extra empty parameter"
60
+ args_to_quote+=("")
61
+ fi
62
+
63
+ # Use Zsh's (q) flag to quote each argument safely for eval
64
+ local quoted_args=("\${(@q)args_to_quote}")
65
+
66
+ # Join the main command and the quoted arguments into a single string for eval
67
+ requestComp="${n2} complete -- \${quoted_args[*]}"
68
+
69
+ __${t2}_debug "About to call: eval \${requestComp}"
70
+
71
+ # Use eval to handle any environment variables and such
72
+ out=$(eval \${requestComp} 2>/dev/null)
73
+ __${t2}_debug "completion output: \${out}"
74
+
75
+ # Extract the directive integer following a : from the last line
76
+ local lastLine
77
+ while IFS='
78
+ ' read -r line; do
79
+ lastLine=\${line}
80
+ done < <(printf "%s
81
+ " "\${out[@]}")
82
+ __${t2}_debug "last line: \${lastLine}"
83
+
84
+ if [ "\${lastLine[1]}" = : ]; then
85
+ directive=\${lastLine[2,-1]}
86
+ # Remove the directive including the : and the newline
87
+ local suffix
88
+ (( suffix=\${#lastLine}+2))
89
+ out=\${out[1,-$suffix]}
90
+ else
91
+ # There is no directive specified. Leave $out as is.
92
+ __${t2}_debug "No directive found. Setting to default"
93
+ directive=0
94
+ fi
95
+
96
+ __${t2}_debug "directive: \${directive}"
97
+ __${t2}_debug "completions: \${out}"
98
+ __${t2}_debug "flagPrefix: \${flagPrefix}"
99
+
100
+ if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
101
+ __${t2}_debug "Completion received error. Ignoring completions."
102
+ return
103
+ fi
104
+
105
+ local activeHelpMarker="%"
106
+ local endIndex=\${#activeHelpMarker}
107
+ local startIndex=$((\${#activeHelpMarker}+1))
108
+ local hasActiveHelp=0
109
+ while IFS='
110
+ ' read -r comp; do
111
+ # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
112
+ if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
113
+ __${t2}_debug "ActiveHelp found: $comp"
114
+ comp="\${comp[$startIndex,-1]}"
115
+ if [ -n "$comp" ]; then
116
+ compadd -x "\${comp}"
117
+ __${t2}_debug "ActiveHelp will need delimiter"
118
+ hasActiveHelp=1
119
+ fi
120
+ continue
121
+ fi
122
+
123
+ if [ -n "$comp" ]; then
124
+ # If requested, completions are returned with a description.
125
+ # The description is preceded by a TAB character.
126
+ # For zsh's _describe, we need to use a : instead of a TAB.
127
+ # We first need to escape any : as part of the completion itself.
128
+ comp=\${comp//:/\\:}
129
+
130
+ local tab="$(printf '\\t')"
131
+ comp=\${comp//$tab/:}
132
+
133
+ __${t2}_debug "Adding completion: \${comp}"
134
+ completions+=\${comp}
135
+ lastComp=$comp
136
+ fi
137
+ done < <(printf "%s
138
+ " "\${out[@]}")
139
+
140
+ # Add a delimiter after the activeHelp statements, but only if:
141
+ # - there are completions following the activeHelp statements, or
142
+ # - file completion will be performed (so there will be choices after the activeHelp)
143
+ if [ $hasActiveHelp -eq 1 ]; then
144
+ if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
145
+ __${t2}_debug "Adding activeHelp delimiter"
146
+ compadd -x "--"
147
+ hasActiveHelp=0
148
+ fi
149
+ fi
150
+
151
+ if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
152
+ __${t2}_debug "Activating nospace."
153
+ noSpace="-S ''"
154
+ fi
155
+
156
+ if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
157
+ __${t2}_debug "Activating keep order."
158
+ keepOrder="-V"
159
+ fi
160
+
161
+ if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
162
+ # File extension filtering
163
+ local filteringCmd
164
+ filteringCmd='_files'
165
+ for filter in \${completions[@]}; do
166
+ if [ \${filter[1]} != '*' ]; then
167
+ # zsh requires a glob pattern to do file filtering
168
+ filter="\\*.$filter"
169
+ fi
170
+ filteringCmd+=" -g $filter"
171
+ done
172
+ filteringCmd+=" \${flagPrefix}"
173
+
174
+ __${t2}_debug "File filtering command: $filteringCmd"
175
+ _arguments '*:filename:'"$filteringCmd"
176
+ elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
177
+ # File completion for directories only
178
+ local subdir
179
+ subdir="\${completions[1]}"
180
+ if [ -n "$subdir" ]; then
181
+ __${t2}_debug "Listing directories in $subdir"
182
+ pushd "\${subdir}" >/dev/null 2>&1
183
+ else
184
+ __${t2}_debug "Listing directories in ."
185
+ fi
186
+
187
+ local result
188
+ _arguments '*:dirname:_files -/'" \${flagPrefix}"
189
+ result=$?
190
+ if [ -n "$subdir" ]; then
191
+ popd >/dev/null 2>&1
192
+ fi
193
+ return $result
194
+ else
195
+ __${t2}_debug "Calling _describe"
196
+ if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
197
+ __${t2}_debug "_describe found some completions"
198
+
199
+ # Return the success of having called _describe
200
+ return 0
201
+ else
202
+ __${t2}_debug "_describe did not find completions."
203
+ __${t2}_debug "Checking if we should do file completion."
204
+ if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
205
+ __${t2}_debug "deactivating file completion"
206
+
207
+ # Return 0 to indicate completion is finished and prevent zsh from
208
+ # trying other completion algorithms (which could cause hanging).
209
+ # We use NoFileComp directive to explicitly disable file completion.
210
+ return 0
211
+ else
212
+ # Perform file completion
213
+ __${t2}_debug "Activating file completion"
214
+
215
+ # We must return the result of this command, so it must be the
216
+ # last command, or else we must store its result to return it.
217
+ _arguments '*:filename:_files'" \${flagPrefix}"
218
+ fi
219
+ fi
220
+ fi
221
+ }
222
+
223
+ # don't run the completion function when being sourced or eval-ed
224
+ if [ "\${funcstack[1]}" = "_${t2}" ]; then
225
+ _${t2}
226
+ fi
227
+ `;
228
+ }
229
+ __name(t, "t");
230
+ function n(t2, n2) {
231
+ let r2 = t2.replace(/[-:]/g, `_`);
232
+ return `# bash completion for ${t2}
233
+
234
+ # Define shell completion directives
235
+ readonly ShellCompDirectiveError=${a.ShellCompDirectiveError}
236
+ readonly ShellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
237
+ readonly ShellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
238
+ readonly ShellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
239
+ readonly ShellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
240
+ readonly ShellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
241
+
242
+ # Function to debug completion
243
+ __${r2}_debug() {
244
+ if [[ -n \${BASH_COMP_DEBUG_FILE:-} ]]; then
245
+ echo "$*" >> "\${BASH_COMP_DEBUG_FILE}"
246
+ fi
247
+ }
248
+
249
+ # Function to handle completions
250
+ __${r2}_complete() {
251
+ local cur prev words cword
252
+ _get_comp_words_by_ref -n "=:" cur prev words cword
253
+
254
+ local requestComp out directive
255
+
256
+ # Build the command to get completions
257
+ requestComp="${n2} complete -- \${words[@]:1}"
258
+
259
+ # Add an empty parameter if the last parameter is complete
260
+ if [[ -z "$cur" ]]; then
261
+ requestComp="$requestComp ''"
262
+ fi
263
+
264
+ # Get completions from the program
265
+ out=$(eval "$requestComp" 2>/dev/null)
266
+
267
+ # Extract directive if present
268
+ directive=0
269
+ if [[ "$out" == *:* ]]; then
270
+ directive=\${out##*:}
271
+ out=\${out%:*}
272
+ fi
273
+
274
+ # Process completions based on directive
275
+ if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then
276
+ # Error, no completion
277
+ return
278
+ fi
279
+
280
+ # Apply directives
281
+ if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then
282
+ compopt -o nospace
283
+ fi
284
+ if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then
285
+ compopt -o nosort
286
+ fi
287
+ if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then
288
+ compopt +o default
289
+ fi
290
+
291
+ # Handle file extension filtering
292
+ if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then
293
+ local filter=""
294
+ for ext in $out; do
295
+ filter="$filter|$ext"
296
+ done
297
+ filter="\\.($filter)"
298
+ compopt -o filenames
299
+ COMPREPLY=( $(compgen -f -X "!$filter" -- "$cur") )
300
+ return
301
+ fi
302
+
303
+ # Handle directory filtering
304
+ if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then
305
+ compopt -o dirnames
306
+ COMPREPLY=( $(compgen -d -- "$cur") )
307
+ return
308
+ fi
309
+
310
+ # Process completions
311
+ local IFS=$'\\n'
312
+ local tab=$(printf '\\t')
313
+
314
+ # Parse completions with descriptions
315
+ local completions=()
316
+ while read -r comp; do
317
+ if [[ "$comp" == *$tab* ]]; then
318
+ # Split completion and description
319
+ local value=\${comp%%$tab*}
320
+ local desc=\${comp#*$tab}
321
+ completions+=("$value")
322
+ else
323
+ completions+=("$comp")
324
+ fi
325
+ done <<< "$out"
326
+
327
+ # Return completions
328
+ COMPREPLY=( $(compgen -W "\${completions[*]}" -- "$cur") )
329
+ }
330
+
331
+ # Register completion function
332
+ complete -F __${r2}_complete ${t2}
333
+ `;
334
+ }
335
+ __name(n, "n");
336
+ function r(t2, n2) {
337
+ let r2 = t2.replace(/[-:]/g, `_`), i3 = a.ShellCompDirectiveError, a2 = a.ShellCompDirectiveNoSpace, o2 = a.ShellCompDirectiveNoFileComp, s2 = a.ShellCompDirectiveFilterFileExt, c2 = a.ShellCompDirectiveFilterDirs;
338
+ return `# fish completion for ${t2} -*- shell-script -*-
339
+
340
+ function __${r2}_debug
341
+ set -l file "$BASH_COMP_DEBUG_FILE"
342
+ if test -n "$file"
343
+ echo "$argv" >> $file
344
+ end
345
+ end
346
+
347
+ function __${r2}_perform_completion
348
+ __${r2}_debug "Starting __${r2}_perform_completion"
349
+
350
+ # Extract all args except the last one
351
+ set -l args (commandline -opc)
352
+ # Extract the token currently being completed (may be empty on a trailing space)
353
+ set -l lastArg (commandline -ct)
354
+
355
+ __${r2}_debug "args: $args"
356
+ __${r2}_debug "last arg: $lastArg"
357
+
358
+ # Pass each arg as its own token (no string join/eval, which would collapse multi-segment paths); quote "$lastArg" so an empty trailing token is still sent.
359
+ __${r2}_debug "Calling ${n2} complete -- $args[2..-1] $lastArg"
360
+ set -l results (${n2} complete -- $args[2..-1] "$lastArg" 2> /dev/null)
361
+
362
+ # Some programs may output extra empty lines after the directive.
363
+ # Let's ignore them or else it will break completion.
364
+ # Ref: https://github.com/spf13/cobra/issues/1279
365
+ for line in $results[-1..1]
366
+ if test (string trim -- $line) = ""
367
+ # Found an empty line, remove it
368
+ set results $results[1..-2]
369
+ else
370
+ # Found non-empty line, we have our proper output
371
+ break
372
+ end
373
+ end
374
+
375
+ set -l comps $results[1..-2]
376
+ set -l directiveLine $results[-1]
377
+
378
+ # For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
379
+ # completions must be prefixed with the flag
380
+ set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
381
+
382
+ __${r2}_debug "Comps: $comps"
383
+ __${r2}_debug "DirectiveLine: $directiveLine"
384
+ __${r2}_debug "flagPrefix: $flagPrefix"
385
+
386
+ for comp in $comps
387
+ printf "%s%s\\n" "$flagPrefix" "$comp"
388
+ end
389
+
390
+ printf "%s\\n" "$directiveLine"
391
+ end
392
+
393
+ # This function limits calls to __${r2}_perform_completion, by caching the result
394
+ function __${r2}_perform_completion_once
395
+ __${r2}_debug "Starting __${r2}_perform_completion_once"
396
+
397
+ if test -n "$__${r2}_perform_completion_once_result"
398
+ __${r2}_debug "Seems like a valid result already exists, skipping __${r2}_perform_completion"
399
+ return 0
400
+ end
401
+
402
+ set --global __${r2}_perform_completion_once_result (__${r2}_perform_completion)
403
+ if test -z "$__${r2}_perform_completion_once_result"
404
+ __${r2}_debug "No completions, probably due to a failure"
405
+ return 1
406
+ end
407
+
408
+ __${r2}_debug "Performed completions and set __${r2}_perform_completion_once_result"
409
+ return 0
410
+ end
411
+
412
+ # This function is used to clear the cached result after completions are run
413
+ function __${r2}_clear_perform_completion_once_result
414
+ __${r2}_debug ""
415
+ __${r2}_debug "========= clearing previously set __${r2}_perform_completion_once_result variable =========="
416
+ set --erase __${r2}_perform_completion_once_result
417
+ __${r2}_debug "Successfully erased the variable __${r2}_perform_completion_once_result"
418
+ end
419
+
420
+ function __${r2}_requires_order_preservation
421
+ __${r2}_debug ""
422
+ __${r2}_debug "========= checking if order preservation is required =========="
423
+
424
+ __${r2}_perform_completion_once
425
+ if test -z "$__${r2}_perform_completion_once_result"
426
+ __${r2}_debug "Error determining if order preservation is required"
427
+ return 1
428
+ end
429
+
430
+ set -l directive (string sub --start 2 $__${r2}_perform_completion_once_result[-1])
431
+ __${r2}_debug "Directive is: $directive"
432
+
433
+ set -l shellCompDirectiveKeepOrder ${a.ShellCompDirectiveKeepOrder}
434
+ set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
435
+ __${r2}_debug "Keeporder is: $keeporder"
436
+
437
+ if test $keeporder -ne 0
438
+ __${r2}_debug "This does require order preservation"
439
+ return 0
440
+ end
441
+
442
+ __${r2}_debug "This doesn't require order preservation"
443
+ return 1
444
+ end
445
+
446
+ # This function does two things:
447
+ # - Obtain the completions and store them in the global __${r2}_comp_results
448
+ # - Return false if file completion should be performed
449
+ function __${r2}_prepare_completions
450
+ __${r2}_debug ""
451
+ __${r2}_debug "========= starting completion logic =========="
452
+
453
+ # Start fresh
454
+ set --erase __${r2}_comp_results
455
+
456
+ __${r2}_perform_completion_once
457
+ __${r2}_debug "Completion results: $__${r2}_perform_completion_once_result"
458
+
459
+ if test -z "$__${r2}_perform_completion_once_result"
460
+ __${r2}_debug "No completion, probably due to a failure"
461
+ # Might as well do file completion, in case it helps
462
+ return 1
463
+ end
464
+
465
+ set -l directive (string sub --start 2 $__${r2}_perform_completion_once_result[-1])
466
+ set --global __${r2}_comp_results $__${r2}_perform_completion_once_result[1..-2]
467
+
468
+ __${r2}_debug "Completions are: $__${r2}_comp_results"
469
+ __${r2}_debug "Directive is: $directive"
470
+
471
+ set -l shellCompDirectiveError ${i3}
472
+ set -l shellCompDirectiveNoSpace ${a2}
473
+ set -l shellCompDirectiveNoFileComp ${o2}
474
+ set -l shellCompDirectiveFilterFileExt ${s2}
475
+ set -l shellCompDirectiveFilterDirs ${c2}
476
+
477
+ if test -z "$directive"
478
+ set directive 0
479
+ end
480
+
481
+ set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
482
+ if test $compErr -eq 1
483
+ __${r2}_debug "Received error directive: aborting."
484
+ # Might as well do file completion, in case it helps
485
+ return 1
486
+ end
487
+
488
+ set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
489
+ set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
490
+ if test $filefilter -eq 1; or test $dirfilter -eq 1
491
+ __${r2}_debug "File extension filtering or directory filtering not supported"
492
+ # Do full file completion instead
493
+ return 1
494
+ end
495
+
496
+ set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
497
+ set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
498
+
499
+ __${r2}_debug "nospace: $nospace, nofiles: $nofiles"
500
+
501
+ # If we want to prevent a space, or if file completion is NOT disabled,
502
+ # we need to count the number of valid completions.
503
+ # To do so, we will filter on prefix as the completions we have received
504
+ # may not already be filtered so as to allow fish to match on different
505
+ # criteria than the prefix.
506
+ if test $nospace -ne 0; or test $nofiles -eq 0
507
+ set -l prefix (commandline -t | string escape --style=regex)
508
+ __${r2}_debug "prefix: $prefix"
509
+
510
+ set -l completions (string match -r -- "^$prefix.*" $__${r2}_comp_results)
511
+ set --global __${r2}_comp_results $completions
512
+ __${r2}_debug "Filtered completions are: $__${r2}_comp_results"
513
+
514
+ # Important not to quote the variable for count to work
515
+ set -l numComps (count $__${r2}_comp_results)
516
+ __${r2}_debug "numComps: $numComps"
517
+
518
+ if test $numComps -eq 1; and test $nospace -ne 0
519
+ # We must first split on \\t to get rid of the descriptions to be
520
+ # able to check what the actual completion will be.
521
+ # We don't need descriptions anyway since there is only a single
522
+ # real completion which the shell will expand immediately.
523
+ set -l split (string split --max 1 "\\t" $__${r2}_comp_results[1])
524
+
525
+ # Fish won't add a space if the completion ends with any
526
+ # of the following characters: @=/:.,
527
+ set -l lastChar (string sub -s -1 -- $split)
528
+ if not string match -r -q "[@=/:.,]" -- "$lastChar"
529
+ # In other cases, to support the "nospace" directive we trick the shell
530
+ # by outputting an extra, longer completion.
531
+ __${r2}_debug "Adding second completion to perform nospace directive"
532
+ set --global __${r2}_comp_results $split[1] $split[1].
533
+ __${r2}_debug "Completions are now: $__${r2}_comp_results"
534
+ end
535
+ end
536
+
537
+ if test $numComps -eq 0; and test $nofiles -eq 0
538
+ # To be consistent with bash and zsh, we only trigger file
539
+ # completion when there are no other completions
540
+ __${r2}_debug "Requesting file completion"
541
+ return 1
542
+ end
543
+ end
544
+
545
+ return 0
546
+ end
547
+
548
+ # Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
549
+ # so we can properly delete any completions provided by another script.
550
+ # Only do this if the program can be found, or else fish may print some errors; besides,
551
+ # the existing completions will only be loaded if the program can be found.
552
+ if type -q "${t2}"
553
+ # The space after the program name is essential to trigger completion for the program
554
+ # and not completion of the program name itself.
555
+ # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
556
+ complete --do-complete "${t2} " > /dev/null 2>&1
557
+ end
558
+
559
+ # Remove any pre-existing completions for the program since we will be handling all of them.
560
+ complete -c ${t2} -e
561
+
562
+ # This will get called after the two calls below and clear the cached result
563
+ complete -c ${t2} -n '__${r2}_clear_perform_completion_once_result'
564
+ # The call to __${r2}_prepare_completions will setup __${r2}_comp_results
565
+ # which provides the program's completion choices.
566
+ # If this doesn't require order preservation, we don't use the -k flag
567
+ complete -c ${t2} -n 'not __${r2}_requires_order_preservation && __${r2}_prepare_completions' -f -a '$__${r2}_comp_results'
568
+ # Otherwise we use the -k flag
569
+ complete -k -c ${t2} -n '__${r2}_requires_order_preservation && __${r2}_prepare_completions' -f -a '$__${r2}_comp_results'
570
+ `;
571
+ }
572
+ __name(r, "r");
573
+ function i(t2, n2) {
574
+ let r2 = t2.replace(/[-:]/g, `_`);
575
+ return `# powershell completion for ${t2} -*- shell-script -*-
576
+
577
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
578
+ function __${t2}_debug {
579
+ if ($env:BASH_COMP_DEBUG_FILE) {
580
+ "$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
581
+ }
582
+ }
583
+
584
+ filter __${t2}_escapeStringWithSpecialChars {
585
+ $_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\`$&'
586
+ }
587
+
588
+ [scriptblock]$__${r2}CompleterBlock = {
589
+ param(
590
+ $WordToComplete,
591
+ $CommandAst,
592
+ $CursorPosition
593
+ )
594
+
595
+ # Get the current command line and convert into a string
596
+ $Command = $CommandAst.CommandElements
597
+ $Command = "$Command"
598
+
599
+ __${t2}_debug ""
600
+ __${t2}_debug "========= starting completion logic =========="
601
+ __${t2}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
602
+
603
+ # The user could have moved the cursor backwards on the command-line.
604
+ # We need to trigger completion from the $CursorPosition location, so we need
605
+ # to truncate the command-line ($Command) up to the $CursorPosition location.
606
+ # Make sure the $Command is longer then the $CursorPosition before we truncate.
607
+ # This happens because the $Command does not include the last space.
608
+ if ($Command.Length -gt $CursorPosition) {
609
+ $Command = $Command.Substring(0, $CursorPosition)
610
+ }
611
+ __${t2}_debug "Truncated command: $Command"
612
+
613
+ $ShellCompDirectiveError=${a.ShellCompDirectiveError}
614
+ $ShellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
615
+ $ShellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
616
+ $ShellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
617
+ $ShellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
618
+ $ShellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
619
+
620
+ # Prepare the command to request completions for the program.
621
+ # Split the command at the first space to separate the program and arguments.
622
+ $Program, $Arguments = $Command.Split(" ", 2)
623
+
624
+ $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
625
+ __${t2}_debug "QuotedArgs: $QuotedArgs"
626
+
627
+ $RequestComp = "& ${n2} complete '--' $QuotedArgs"
628
+ __${t2}_debug "RequestComp: $RequestComp"
629
+
630
+ # we cannot use $WordToComplete because it
631
+ # has the wrong values if the cursor was moved
632
+ # so use the last argument
633
+ if ($WordToComplete -ne "" ) {
634
+ $WordToComplete = $Arguments.Split(" ")[-1]
635
+ }
636
+ __${t2}_debug "New WordToComplete: $WordToComplete"
637
+
638
+
639
+ # Check for flag with equal sign
640
+ $IsEqualFlag = ($WordToComplete -Like "--*=*" )
641
+ if ( $IsEqualFlag ) {
642
+ __${t2}_debug "Completing equal sign flag"
643
+ # Remove the flag part
644
+ $Flag, $WordToComplete = $WordToComplete.Split("=", 2)
645
+ }
646
+ $HasTrailingEmptyArg = $QuotedArgs -match "(^| )''$"
647
+ __${t2}_debug "HasTrailingEmptyArg: $HasTrailingEmptyArg"
648
+
649
+ if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag ) -And ( -Not $HasTrailingEmptyArg )) {
650
+ # If the last parameter is complete (there is a space following it)
651
+ # We add an extra empty parameter so we can indicate this to the go method.
652
+ __${t2}_debug "Adding extra empty parameter"
653
+ # PowerShell 7.2+ changed the way how the arguments are passed to executables,
654
+ # so for pre-7.2 or when Legacy argument passing is enabled we need to use
655
+ if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
656
+ ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or
657
+ (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and
658
+ $PSNativeCommandArgumentPassing -eq 'Legacy')) {
659
+ $RequestComp="$RequestComp" + ' \`"\`"'
660
+ } else {
661
+ $RequestComp = "$RequestComp" + ' ""'
662
+ }
663
+ }
664
+
665
+ __${t2}_debug "Calling $RequestComp"
666
+ # First disable ActiveHelp which is not supported for Powershell
667
+ $env:ActiveHelp = 0
668
+
669
+ # call the command store the output in $out and redirect stderr and stdout to null
670
+ # $Out is an array contains each line per element
671
+ Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
672
+
673
+ # get directive from last line
674
+ [int]$Directive = $Out[-1].TrimStart(':')
675
+ if ($Directive -eq "") {
676
+ # There is no directive specified
677
+ $Directive = 0
678
+ }
679
+ __${t2}_debug "The completion directive is: $Directive"
680
+
681
+ # remove directive (last element) from out
682
+ $Out = $Out | Where-Object { $_ -ne $Out[-1] }
683
+ __${t2}_debug "The completions are: $Out"
684
+
685
+ if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
686
+ # Error code. No completion.
687
+ __${t2}_debug "Received error from custom completion go code"
688
+ return
689
+ }
690
+
691
+ $Longest = 0
692
+ [Array]$Values = $Out | ForEach-Object {
693
+ # Split the output in name and description
694
+ $Name, $Description = $_.Split("\`t", 2)
695
+ __${t2}_debug "Name: $Name Description: $Description"
696
+
697
+ # Look for the longest completion so that we can format things nicely
698
+ if ($Longest -lt $Name.Length) {
699
+ $Longest = $Name.Length
700
+ }
701
+
702
+ # Set the description to a one space string if there is none set.
703
+ # This is needed because the CompletionResult does not accept an empty string as argument
704
+ if (-Not $Description) {
705
+ $Description = " "
706
+ }
707
+ @{ Name = "$Name"; Description = "$Description" }
708
+ }
709
+
710
+
711
+ $Space = " "
712
+ if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
713
+ # remove the space here
714
+ __${t2}_debug "ShellCompDirectiveNoSpace is called"
715
+ $Space = ""
716
+ }
717
+
718
+ if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
719
+ (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
720
+ __${t2}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
721
+
722
+ # return here to prevent the completion of the extensions
723
+ return
724
+ }
725
+
726
+ $Values = $Values | Where-Object {
727
+ # filter the result
728
+ $_.Name -like "$WordToComplete*"
729
+
730
+ # Join the flag back if we have an equal sign flag
731
+ if ( $IsEqualFlag ) {
732
+ __${t2}_debug "Join the equal sign flag back to the completion value"
733
+ $_.Name = $Flag + "=" + $_.Name
734
+ }
735
+ }
736
+
737
+ # we sort the values in ascending order by name if keep order isn't passed
738
+ if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {
739
+ $Values = $Values | Sort-Object -Property Name
740
+ }
741
+
742
+ if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
743
+ __${t2}_debug "ShellCompDirectiveNoFileComp is called"
744
+
745
+ if ($Values.Length -eq 0) {
746
+ # Just print an empty string here so the
747
+ # shell does not start to complete paths.
748
+ # We cannot use CompletionResult here because
749
+ # it does not accept an empty string as argument.
750
+ ""
751
+ return
752
+ }
753
+ }
754
+
755
+ # Get the current mode
756
+ $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
757
+ __${t2}_debug "Mode: $Mode"
758
+
759
+ $Values | ForEach-Object {
760
+
761
+ # store temporary because switch will overwrite $_
762
+ $comp = $_
763
+
764
+ # PowerShell supports three different completion modes
765
+ # - TabCompleteNext (default windows style - on each key press the next option is displayed)
766
+ # - Complete (works like bash)
767
+ # - MenuComplete (works like zsh)
768
+ # You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
769
+
770
+ # CompletionResult Arguments:
771
+ # 1) CompletionText text to be used as the auto completion result
772
+ # 2) ListItemText text to be displayed in the suggestion list
773
+ # 3) ResultType type of completion result
774
+ # 4) ToolTip text for the tooltip with details about the object
775
+
776
+ switch ($Mode) {
777
+
778
+ # bash like
779
+ "Complete" {
780
+
781
+ if ($Values.Length -eq 1) {
782
+ __${t2}_debug "Only one completion left"
783
+
784
+ # insert space after value
785
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${t2}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
786
+
787
+ } else {
788
+ # Add the proper number of spaces to align the descriptions
789
+ while($comp.Name.Length -lt $Longest) {
790
+ $comp.Name = $comp.Name + " "
791
+ }
792
+
793
+ # Check for empty description and only add parentheses if needed
794
+ if ($($comp.Description) -eq " " ) {
795
+ $Description = ""
796
+ } else {
797
+ $Description = " ($($comp.Description))"
798
+ }
799
+
800
+ [System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
801
+ }
802
+ }
803
+
804
+ # zsh like
805
+ "MenuComplete" {
806
+ # insert space after value
807
+ # MenuComplete will automatically show the ToolTip of
808
+ # the highlighted value at the bottom of the suggestions.
809
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${t2}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
810
+ }
811
+
812
+ # TabCompleteNext and in case we get something unknown
813
+ Default {
814
+ # Like MenuComplete but we don't want to add a space here because
815
+ # the user need to press space anyway to get the completion.
816
+ # Description will not be shown because that's not possible with TabCompleteNext
817
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${t2}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
818
+ }
819
+ }
820
+
821
+ }
822
+ }
823
+
824
+ Register-ArgumentCompleter -CommandName '${t2}' -ScriptBlock $__${r2}CompleterBlock
825
+ `;
826
+ }
827
+ __name(i, "i");
828
+
829
+ // node_modules/.pnpm/@bomb.sh+tab@0.0.22_commander@15.0.0/node_modules/@bomb.sh/tab/dist/index.mjs
830
+ import i2 from "node:assert";
831
+ var a = { ShellCompDirectiveError: 1, ShellCompDirectiveNoSpace: 2, ShellCompDirectiveNoFileComp: 4, ShellCompDirectiveFilterFileExt: 8, ShellCompDirectiveFilterDirs: 16, ShellCompDirectiveKeepOrder: 32, shellCompDirectiveMaxValue: 64, ShellCompDirectiveDefault: 0 };
832
+ var o = class {
833
+ static {
834
+ __name(this, "o");
835
+ }
836
+ name;
837
+ variadic;
838
+ command;
839
+ handler;
840
+ constructor(e, t2, n2, r2 = false) {
841
+ this.command = e, this.name = t2, this.handler = n2, this.variadic = r2;
842
+ }
843
+ };
844
+ var s = class {
845
+ static {
846
+ __name(this, "s");
847
+ }
848
+ value;
849
+ description;
850
+ command;
851
+ handler;
852
+ alias;
853
+ isBoolean;
854
+ constructor(e, t2, n2, r2, i3, a2) {
855
+ this.command = e, this.value = t2, this.description = n2, this.handler = r2, this.alias = i3, this.isBoolean = a2;
856
+ }
857
+ };
858
+ var c = class {
859
+ static {
860
+ __name(this, "c");
861
+ }
862
+ value;
863
+ description;
864
+ options = /* @__PURE__ */ new Map();
865
+ arguments = /* @__PURE__ */ new Map();
866
+ parent;
867
+ constructor(e, t2) {
868
+ this.value = e, this.description = t2;
869
+ }
870
+ option(e, t2, n2, r2) {
871
+ let i3, a2, o2;
872
+ typeof n2 == `function` ? (i3 = n2, a2 = r2, o2 = false) : typeof n2 == `string` ? (i3 = void 0, a2 = n2, o2 = true) : (i3 = void 0, a2 = void 0, o2 = true);
873
+ let c2 = new s(this, e, t2, i3, a2, o2);
874
+ return this.options.set(e, c2), this;
875
+ }
876
+ argument(e, t2, n2 = false) {
877
+ let r2 = new o(this, e, t2, n2);
878
+ return this.arguments.set(e, r2), this;
879
+ }
880
+ };
881
+ var l = class extends c {
882
+ static {
883
+ __name(this, "l");
884
+ }
885
+ commands = /* @__PURE__ */ new Map();
886
+ completions = [];
887
+ directive = a.ShellCompDirectiveDefault;
888
+ constructor() {
889
+ super(``, ``);
890
+ }
891
+ command(e, t2) {
892
+ let n2 = new c(e, t2);
893
+ return this.commands.set(e, n2), n2;
894
+ }
895
+ stripOptions(e) {
896
+ let t2 = [], n2 = 0;
897
+ for (; n2 < e.length; ) {
898
+ let r2 = e[n2];
899
+ if (r2.startsWith(`-`)) {
900
+ n2++;
901
+ let t3 = false, i3 = this.findOption(this, r2);
902
+ if (i3) t3 = i3.isBoolean ?? false;
903
+ else for (let [, e2] of this.commands) {
904
+ let n3 = this.findOption(e2, r2);
905
+ if (n3) {
906
+ t3 = n3.isBoolean ?? false;
907
+ break;
908
+ }
909
+ }
910
+ !t3 && n2 < e.length && !e[n2].startsWith(`-`) && n2++;
911
+ } else t2.push(r2), n2++;
912
+ }
913
+ return t2;
914
+ }
915
+ matchCommand(e) {
916
+ e = this.stripOptions(e);
917
+ let t2 = [], n2 = [], r2 = null;
918
+ for (let i3 = 0; i3 < e.length; i3++) {
919
+ let a2 = e[i3];
920
+ t2.push(a2);
921
+ let o2 = this.commands.get(t2.join(` `));
922
+ if (o2) r2 = o2;
923
+ else {
924
+ n2 = e.slice(i3, e.length);
925
+ break;
926
+ }
927
+ }
928
+ return [r2 || this, n2];
929
+ }
930
+ shouldCompleteFlags(e, t2) {
931
+ if (t2.startsWith(`-`)) return true;
932
+ if (e?.startsWith(`-`)) {
933
+ let t3 = this.findOption(this, e);
934
+ if (!t3) {
935
+ for (let [, n2] of this.commands) if (t3 = this.findOption(n2, e), t3) break;
936
+ }
937
+ return !(t3 && t3.isBoolean);
938
+ }
939
+ return false;
940
+ }
941
+ shouldCompleteCommands(e) {
942
+ return !e.startsWith(`-`);
943
+ }
944
+ handleFlagCompletion(e, t2, n2, r2) {
945
+ let i3;
946
+ if (n2.includes(`=`)) {
947
+ let [e2] = n2.split(`=`);
948
+ i3 = e2;
949
+ } else if (r2?.startsWith(`-`)) {
950
+ let t3 = this.findOption(e, r2);
951
+ t3 && !t3.isBoolean && (i3 = r2);
952
+ }
953
+ if (i3) {
954
+ let t3 = this.findOption(e, i3);
955
+ if (t3?.handler) {
956
+ let n3 = [];
957
+ t3.handler.call(t3, (e2, t4) => n3.push({ value: e2, description: t4 }), e.options), this.completions = n3;
958
+ }
959
+ return;
960
+ }
961
+ if (n2.startsWith(`-`)) {
962
+ let t3 = n2.startsWith(`-`) && !n2.startsWith(`--`), r3 = n2.replace(/^-+/, ``);
963
+ for (let [i4, a2] of e.options) t3 && a2.alias && `-${a2.alias}`.startsWith(n2) ? this.completions.push({ value: `-${a2.alias}`, description: a2.description }) : !t3 && i4.startsWith(r3) && this.completions.push({ value: `--${i4}`, description: a2.description });
964
+ }
965
+ }
966
+ findOption(e, t2) {
967
+ let n2 = e.options.get(t2);
968
+ if (n2 || (n2 = e.options.get(t2.replace(/^-+/, ``)), n2)) return n2;
969
+ for (let [n3, r2] of e.options) if (r2.alias && `-${r2.alias}` === t2) return r2;
970
+ }
971
+ handleCommandCompletion(e, t2) {
972
+ let n2 = this.stripOptions(e);
973
+ for (let [e2, r2] of this.commands) {
974
+ if (e2 === ``) continue;
975
+ let i3 = e2.split(` `);
976
+ i3.slice(0, n2.length).every((e3, t3) => e3 === n2[t3]) && i3[n2.length]?.startsWith(t2) && this.completions.push({ value: i3[n2.length], description: r2.description });
977
+ }
978
+ }
979
+ handlePositionalCompletion(e, t2) {
980
+ let n2 = this.stripOptions(t2), r2 = e.value.split(` `).length, i3 = Math.max(0, n2.length - r2), a2 = Array.from(e.arguments.entries());
981
+ if (a2.length > 0) {
982
+ let t3;
983
+ if (i3 < a2.length) {
984
+ let [e2, n3] = a2[i3];
985
+ t3 = n3;
986
+ } else {
987
+ let e2 = a2[a2.length - 1][1];
988
+ e2.variadic && (t3 = e2);
989
+ }
990
+ if (t3 && t3.handler && typeof t3.handler == `function`) {
991
+ let n3 = [];
992
+ t3.handler.call(t3, (e2, t4) => n3.push({ value: e2, description: t4 }), e.options), this.completions.push(...n3);
993
+ }
994
+ }
995
+ }
996
+ complete(e) {
997
+ this.directive = a.ShellCompDirectiveNoFileComp;
998
+ let t2 = /* @__PURE__ */ new Set();
999
+ this.completions.filter((e2) => t2.has(e2.value) ? false : (t2.add(e2.value), true)).filter((t3) => {
1000
+ if (e.includes(`=`)) {
1001
+ let [, n2] = e.split(`=`);
1002
+ return t3.value.startsWith(n2);
1003
+ }
1004
+ return t3.value.startsWith(e);
1005
+ }).forEach((e2) => console.log(`${e2.value} ${e2.description ?? ``}`)), console.log(`:${this.directive}`);
1006
+ }
1007
+ parse(e) {
1008
+ this.completions = [];
1009
+ let t2 = e[e.length - 1] === ``;
1010
+ t2 && e.pop();
1011
+ let n2 = e[e.length - 1] || ``, r2 = e.slice(0, -1);
1012
+ t2 && (n2 !== `` && r2.push(n2), n2 = ``);
1013
+ let [i3] = this.matchCommand(r2), a2 = r2[r2.length - 1];
1014
+ this.shouldCompleteFlags(a2, n2) ? this.handleFlagCompletion(i3, r2, n2, a2) : (this.shouldCompleteCommands(n2) && this.handleCommandCompletion(r2, n2), i3 && i3.arguments.size > 0 && this.handlePositionalCompletion(i3, r2)), this.complete(n2);
1015
+ }
1016
+ setup(a2, o2, s2) {
1017
+ switch (i2(s2 === `zsh` || s2 === `bash` || s2 === `fish` || s2 === `powershell`, `Unsupported shell`), s2) {
1018
+ case `zsh`: {
1019
+ let t2 = t(a2, o2);
1020
+ console.log(t2);
1021
+ break;
1022
+ }
1023
+ case `bash`: {
1024
+ let e = n(a2, o2);
1025
+ console.log(e);
1026
+ break;
1027
+ }
1028
+ case `fish`: {
1029
+ let e = r(a2, o2);
1030
+ console.log(e);
1031
+ break;
1032
+ }
1033
+ case `powershell`: {
1034
+ let e = i(a2, o2);
1035
+ console.log(e);
1036
+ break;
1037
+ }
1038
+ }
1039
+ }
1040
+ };
1041
+ var u = new l();
1042
+ function d(e, t2, n2) {
1043
+ u.setup(t2, n2, e);
1044
+ }
1045
+ __name(d, "d");
1046
+
1047
+ export {
1048
+ a,
1049
+ o,
1050
+ s,
1051
+ c,
1052
+ l,
1053
+ u,
1054
+ d
1055
+ };