varlock 1.3.0 → 1.4.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.
- package/dist/audit.command-PXY2ZGU2.js +16 -0
- package/dist/{audit.command-LLD5UIAW.js.map → audit.command-PXY2ZGU2.js.map} +1 -1
- package/dist/{chunk-HMWAOBZR.js → chunk-2GZ4APXU.js} +7 -7
- package/dist/{chunk-HMWAOBZR.js.map → chunk-2GZ4APXU.js.map} +1 -1
- package/dist/{chunk-XXSPHSF7.js → chunk-66VKZYD7.js} +6 -6
- package/dist/{chunk-XXSPHSF7.js.map → chunk-66VKZYD7.js.map} +1 -1
- package/dist/{chunk-MPHVA4WC.js → chunk-7VERU3F7.js} +3 -3
- package/dist/{chunk-MPHVA4WC.js.map → chunk-7VERU3F7.js.map} +1 -1
- package/dist/{chunk-RQZZDYWL.js → chunk-A5L3SRQS.js} +7 -7
- package/dist/{chunk-RQZZDYWL.js.map → chunk-A5L3SRQS.js.map} +1 -1
- package/dist/{chunk-WTBUNHUJ.js → chunk-DQTUCLA7.js} +5 -5
- package/dist/{chunk-WTBUNHUJ.js.map → chunk-DQTUCLA7.js.map} +1 -1
- package/dist/{chunk-NW4KR67N.js → chunk-EGFAEO7L.js} +7 -7
- package/dist/{chunk-NW4KR67N.js.map → chunk-EGFAEO7L.js.map} +1 -1
- package/dist/{chunk-WJLMLKSG.js → chunk-F64DA7XN.js} +6 -6
- package/dist/{chunk-WJLMLKSG.js.map → chunk-F64DA7XN.js.map} +1 -1
- package/dist/{chunk-4A54P4EM.js → chunk-MGUGRIW2.js} +1185 -1152
- package/dist/chunk-MGUGRIW2.js.map +1 -0
- package/dist/{chunk-F6ZYIWAR.js → chunk-N7FJTNE5.js} +11 -5
- package/dist/chunk-N7FJTNE5.js.map +1 -0
- package/dist/{chunk-XUY3HAO2.js → chunk-NHNQJTPB.js} +4 -4
- package/dist/{chunk-XUY3HAO2.js.map → chunk-NHNQJTPB.js.map} +1 -1
- package/dist/{chunk-INGOLNLE.js → chunk-NZTQKZND.js} +4 -4
- package/dist/{chunk-INGOLNLE.js.map → chunk-NZTQKZND.js.map} +1 -1
- package/dist/{chunk-YWTIKDGU.js → chunk-P4HNABAM.js} +98 -20
- package/dist/chunk-P4HNABAM.js.map +1 -0
- package/dist/{chunk-GKN3UJNE.js → chunk-PBWMMYWL.js} +520 -373
- package/dist/chunk-PBWMMYWL.js.map +1 -0
- package/dist/{chunk-C5LW5EET.js → chunk-Q4I7MXFB.js} +5 -5
- package/dist/{chunk-C5LW5EET.js.map → chunk-Q4I7MXFB.js.map} +1 -1
- package/dist/{chunk-GJ7PTJM4.js → chunk-Q7XUQDLE.js} +3 -3
- package/dist/{chunk-GJ7PTJM4.js.map → chunk-Q7XUQDLE.js.map} +1 -1
- package/dist/{chunk-IO2OGZQU.js → chunk-ROZITJAP.js} +7 -7
- package/dist/{chunk-IO2OGZQU.js.map → chunk-ROZITJAP.js.map} +1 -1
- package/dist/{chunk-CESFJIM4.js → chunk-RTKFINP6.js} +6 -6
- package/dist/{chunk-CESFJIM4.js.map → chunk-RTKFINP6.js.map} +1 -1
- package/dist/{chunk-5DRCCFKV.js → chunk-RWXFFQWH.js} +4 -4
- package/dist/{chunk-5DRCCFKV.js.map → chunk-RWXFFQWH.js.map} +1 -1
- package/dist/{chunk-JOGGSYT2.js → chunk-SX2NUZCL.js} +3 -3
- package/dist/{chunk-JOGGSYT2.js.map → chunk-SX2NUZCL.js.map} +1 -1
- package/dist/{chunk-KI5QLKPU.js → chunk-T3NMDBCU.js} +5 -5
- package/dist/{chunk-KI5QLKPU.js.map → chunk-T3NMDBCU.js.map} +1 -1
- package/dist/{chunk-HH647LSU.js → chunk-YZCCCHDD.js} +6 -6
- package/dist/{chunk-HH647LSU.js.map → chunk-YZCCCHDD.js.map} +1 -1
- package/dist/{chunk-OGGTDFVX.js → chunk-ZCYV47TZ.js} +7 -7
- package/dist/{chunk-OGGTDFVX.js.map → chunk-ZCYV47TZ.js.map} +1 -1
- package/dist/cli/cli-executable.js +1545 -38
- package/dist/cli/cli-executable.js.map +1 -1
- package/dist/config-item-HMRJLPJY.js +7 -0
- package/dist/{config-item-SQFJ2BJ2.js.map → config-item-HMRJLPJY.js.map} +1 -1
- package/dist/encrypt.command-7M34IUJY.js +14 -0
- package/dist/{encrypt.command-WISNYCTG.js.map → encrypt.command-7M34IUJY.js.map} +1 -1
- package/dist/explain.command-LZJOP4TM.js +15 -0
- package/dist/{explain.command-THO6CRHD.js.map → explain.command-LZJOP4TM.js.map} +1 -1
- package/dist/help.command-VIBYZWCF.js +5 -0
- package/dist/{help.command-7E52XAOO.js.map → help.command-VIBYZWCF.js.map} +1 -1
- package/dist/index.js +6 -6
- package/dist/init.command-FFORG2JL.js +14 -0
- package/dist/{init.command-3EDACW36.js.map → init.command-FFORG2JL.js.map} +1 -1
- package/dist/install-plugin.command-SFNHDKVE.js +13 -0
- package/dist/{install-plugin.command-MXBZTBTE.js.map → install-plugin.command-SFNHDKVE.js.map} +1 -1
- package/dist/load.command-V3C5H6CZ.js +15 -0
- package/dist/{load.command-XRABTXAE.js.map → load.command-V3C5H6CZ.js.map} +1 -1
- package/dist/lock.command-QQV2S6NY.js +7 -0
- package/dist/{lock.command-O5MPBQ2I.js.map → lock.command-QQV2S6NY.js.map} +1 -1
- package/dist/printenv.command-2BIP7FCF.js +15 -0
- package/dist/{printenv.command-DLCI4IPZ.js.map → printenv.command-2BIP7FCF.js.map} +1 -1
- package/dist/reveal.command-7LHNCYS4.js +15 -0
- package/dist/{reveal.command-6BTK3FJZ.js.map → reveal.command-7LHNCYS4.js.map} +1 -1
- package/dist/run.command-TRSRYDOM.js +16 -0
- package/dist/{run.command-5CIHZECD.js.map → run.command-TRSRYDOM.js.map} +1 -1
- package/dist/{scan.command-PW3OOLQY.js → scan.command-NMBEPFUC.js} +9 -9
- package/dist/{scan.command-PW3OOLQY.js.map → scan.command-NMBEPFUC.js.map} +1 -1
- package/dist/telemetry.command-SMIT5ZZB.js +13 -0
- package/dist/{telemetry.command-TZDNG2WR.js.map → telemetry.command-SMIT5ZZB.js.map} +1 -1
- package/dist/typegen.command-C5KWLYPL.js +14 -0
- package/dist/{typegen.command-QD26Q3MP.js.map → typegen.command-C5KWLYPL.js.map} +1 -1
- package/native-bins/darwin/VarlockEnclave.app/Contents/CodeResources +0 -0
- package/native-bins/darwin/VarlockEnclave.app/Contents/MacOS/varlock-local-encrypt +0 -0
- package/native-bins/linux-arm64/varlock-local-encrypt +0 -0
- package/native-bins/linux-x64/varlock-local-encrypt +0 -0
- package/native-bins/win32-x64/varlock-local-encrypt.exe +0 -0
- package/package.json +4 -3
- package/dist/audit.command-LLD5UIAW.js +0 -16
- package/dist/chunk-4A54P4EM.js.map +0 -1
- package/dist/chunk-F6ZYIWAR.js.map +0 -1
- package/dist/chunk-GKN3UJNE.js.map +0 -1
- package/dist/chunk-YWTIKDGU.js.map +0 -1
- package/dist/config-item-SQFJ2BJ2.js +0 -7
- package/dist/encrypt.command-WISNYCTG.js +0 -14
- package/dist/explain.command-THO6CRHD.js +0 -15
- package/dist/help.command-7E52XAOO.js +0 -5
- package/dist/init.command-3EDACW36.js +0 -14
- package/dist/install-plugin.command-MXBZTBTE.js +0 -13
- package/dist/load.command-XRABTXAE.js +0 -15
- package/dist/lock.command-O5MPBQ2I.js +0 -7
- package/dist/printenv.command-DLCI4IPZ.js +0 -15
- package/dist/reveal.command-6BTK3FJZ.js +0 -15
- package/dist/run.command-5CIHZECD.js +0 -16
- package/dist/telemetry.command-TZDNG2WR.js +0 -13
- package/dist/typegen.command-QD26Q3MP.js +0 -14
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
import { commandSpec as commandSpec$d } from '../chunk-
|
|
2
|
-
import { commandSpec as commandSpec$b } from '../chunk-
|
|
3
|
-
import { commandSpec as commandSpec$4 } from '../chunk-
|
|
4
|
-
import { commandSpec as commandSpec$5 } from '../chunk-
|
|
5
|
-
import { commandSpec as commandSpec$6 } from '../chunk-
|
|
6
|
-
import { commandSpec as commandSpec$8 } from '../chunk-
|
|
7
|
-
import { commandSpec as commandSpec$9 } from '../chunk-
|
|
8
|
-
import { commandSpec as commandSpec$7 } from '../chunk-
|
|
9
|
-
import { commandSpec as commandSpec$a } from '../chunk-
|
|
1
|
+
import { commandSpec as commandSpec$d } from '../chunk-F64DA7XN.js';
|
|
2
|
+
import { commandSpec as commandSpec$b } from '../chunk-RTKFINP6.js';
|
|
3
|
+
import { commandSpec as commandSpec$4 } from '../chunk-ROZITJAP.js';
|
|
4
|
+
import { commandSpec as commandSpec$5 } from '../chunk-RWXFFQWH.js';
|
|
5
|
+
import { commandSpec as commandSpec$6 } from '../chunk-A5L3SRQS.js';
|
|
6
|
+
import { commandSpec as commandSpec$8 } from '../chunk-Q7XUQDLE.js';
|
|
7
|
+
import { commandSpec as commandSpec$9 } from '../chunk-DQTUCLA7.js';
|
|
8
|
+
import { commandSpec as commandSpec$7 } from '../chunk-ZCYV47TZ.js';
|
|
9
|
+
import { commandSpec as commandSpec$a } from '../chunk-EGFAEO7L.js';
|
|
10
10
|
import '../chunk-GXNQVEXD.js';
|
|
11
|
-
import { commandSpec as commandSpec$c } from '../chunk-
|
|
12
|
-
import { commandSpec } from '../chunk-
|
|
11
|
+
import { commandSpec as commandSpec$c } from '../chunk-YZCCCHDD.js';
|
|
12
|
+
import { commandSpec } from '../chunk-N7FJTNE5.js';
|
|
13
13
|
import '../chunk-P33JXOU6.js';
|
|
14
|
-
import { fmt } from '../chunk-
|
|
15
|
-
import { commandSpec as commandSpec$1 } from '../chunk-
|
|
16
|
-
import { commandSpec as commandSpec$2 } from '../chunk-
|
|
17
|
-
import { commandSpec as commandSpec$3 } from '../chunk-
|
|
14
|
+
import { fmt } from '../chunk-NZTQKZND.js';
|
|
15
|
+
import { commandSpec as commandSpec$1 } from '../chunk-2GZ4APXU.js';
|
|
16
|
+
import { commandSpec as commandSpec$2 } from '../chunk-T3NMDBCU.js';
|
|
17
|
+
import { commandSpec as commandSpec$3 } from '../chunk-66VKZYD7.js';
|
|
18
18
|
import { gracefulExit, asyncExitHook } from '../chunk-CHQDS2PI.js';
|
|
19
|
-
import { cli } from '../chunk-
|
|
20
|
-
import { checkBunVersion } from '../chunk-
|
|
21
|
-
import { InvalidEnvError } from '../chunk-
|
|
22
|
-
import '../chunk-
|
|
23
|
-
import '../chunk-
|
|
24
|
-
import { CliExitError } from '../chunk-
|
|
25
|
-
import { ansis_default } from '../chunk-
|
|
19
|
+
import { cli } from '../chunk-MGUGRIW2.js';
|
|
20
|
+
import { checkBunVersion } from '../chunk-7VERU3F7.js';
|
|
21
|
+
import { InvalidEnvError } from '../chunk-NHNQJTPB.js';
|
|
22
|
+
import '../chunk-Q4I7MXFB.js';
|
|
23
|
+
import '../chunk-P4HNABAM.js';
|
|
24
|
+
import { CliExitError } from '../chunk-SX2NUZCL.js';
|
|
25
|
+
import { ansis_default } from '../chunk-PBWMMYWL.js';
|
|
26
26
|
import { getUserVarlockDir } from '../chunk-O3WTD6L4.js';
|
|
27
27
|
import '../chunk-IRXBCLL2.js';
|
|
28
28
|
import { createDebug } from '../chunk-FA5SNEKN.js';
|
|
29
29
|
import '../chunk-UUJK65RS.js';
|
|
30
30
|
import '../chunk-XLYSNOR3.js';
|
|
31
31
|
import { __commonJS, __name, __toESM } from '../chunk-6PEHRAEP.js';
|
|
32
|
+
import i2 from 'assert';
|
|
32
33
|
import os2 from 'os';
|
|
33
34
|
import crypto, { createHash } from 'crypto';
|
|
34
35
|
import { join, dirname } from 'path';
|
|
@@ -485,6 +486,1491 @@ var require_ci_info = __commonJS({
|
|
|
485
486
|
__name(checkPR, "checkPR");
|
|
486
487
|
}
|
|
487
488
|
});
|
|
489
|
+
|
|
490
|
+
// ../../node_modules/.bun/@bomb.sh+tab@0.0.15+d2aa7bd88f16ef93/node_modules/@bomb.sh/tab/dist/powershell-CHePOaos.mjs
|
|
491
|
+
function t(t2, n2) {
|
|
492
|
+
return `#compdef ${t2}
|
|
493
|
+
compdef _${t2} ${t2}
|
|
494
|
+
|
|
495
|
+
# zsh completion for ${t2} -*- shell-script -*-
|
|
496
|
+
|
|
497
|
+
__${t2}_debug() {
|
|
498
|
+
local file="$BASH_COMP_DEBUG_FILE"
|
|
499
|
+
if [[ -n \${file} ]]; then
|
|
500
|
+
echo "$*" >> "\${file}"
|
|
501
|
+
fi
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
_${t2}() {
|
|
505
|
+
local shellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
506
|
+
local shellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
507
|
+
local shellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
508
|
+
local shellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
509
|
+
local shellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
510
|
+
local shellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
511
|
+
|
|
512
|
+
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
|
513
|
+
local -a completions
|
|
514
|
+
|
|
515
|
+
__${t2}_debug "\\n========= starting completion logic =========="
|
|
516
|
+
__${t2}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
|
|
517
|
+
|
|
518
|
+
# The user could have moved the cursor backwards on the command-line.
|
|
519
|
+
# We need to trigger completion from the $CURRENT location, so we need
|
|
520
|
+
# to truncate the command-line ($words) up to the $CURRENT location.
|
|
521
|
+
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
|
|
522
|
+
words=( "\${=words[1,CURRENT]}" )
|
|
523
|
+
__${t2}_debug "Truncated words[*]: \${words[*]},"
|
|
524
|
+
|
|
525
|
+
lastParam=\${words[-1]}
|
|
526
|
+
lastChar=\${lastParam[-1]}
|
|
527
|
+
__${t2}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
|
|
528
|
+
|
|
529
|
+
# For zsh, when completing a flag with an = (e.g., ${t2} -n=<TAB>)
|
|
530
|
+
# completions must be prefixed with the flag
|
|
531
|
+
setopt local_options BASH_REMATCH
|
|
532
|
+
if [[ "\${lastParam}" =~ '-.*=' ]]; then
|
|
533
|
+
# We are dealing with a flag with an =
|
|
534
|
+
flagPrefix="-P \${BASH_REMATCH}"
|
|
535
|
+
fi
|
|
536
|
+
|
|
537
|
+
# Prepare the command to obtain completions, ensuring arguments are quoted for eval
|
|
538
|
+
local -a args_to_quote=("\${(@)words[2,-1]}")
|
|
539
|
+
if [ "\${lastChar}" = "" ]; then
|
|
540
|
+
# If the last parameter is complete (there is a space following it)
|
|
541
|
+
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
542
|
+
__${t2}_debug "Adding extra empty parameter"
|
|
543
|
+
args_to_quote+=("")
|
|
544
|
+
fi
|
|
545
|
+
|
|
546
|
+
# Use Zsh's (q) flag to quote each argument safely for eval
|
|
547
|
+
local quoted_args=("\${(@q)args_to_quote}")
|
|
548
|
+
|
|
549
|
+
# Join the main command and the quoted arguments into a single string for eval
|
|
550
|
+
requestComp="${n2} complete -- \${quoted_args[*]}"
|
|
551
|
+
|
|
552
|
+
__${t2}_debug "About to call: eval \${requestComp}"
|
|
553
|
+
|
|
554
|
+
# Use eval to handle any environment variables and such
|
|
555
|
+
out=$(eval \${requestComp} 2>/dev/null)
|
|
556
|
+
__${t2}_debug "completion output: \${out}"
|
|
557
|
+
|
|
558
|
+
# Extract the directive integer following a : from the last line
|
|
559
|
+
local lastLine
|
|
560
|
+
while IFS='
|
|
561
|
+
' read -r line; do
|
|
562
|
+
lastLine=\${line}
|
|
563
|
+
done < <(printf "%s
|
|
564
|
+
" "\${out[@]}")
|
|
565
|
+
__${t2}_debug "last line: \${lastLine}"
|
|
566
|
+
|
|
567
|
+
if [ "\${lastLine[1]}" = : ]; then
|
|
568
|
+
directive=\${lastLine[2,-1]}
|
|
569
|
+
# Remove the directive including the : and the newline
|
|
570
|
+
local suffix
|
|
571
|
+
(( suffix=\${#lastLine}+2))
|
|
572
|
+
out=\${out[1,-$suffix]}
|
|
573
|
+
else
|
|
574
|
+
# There is no directive specified. Leave $out as is.
|
|
575
|
+
__${t2}_debug "No directive found. Setting to default"
|
|
576
|
+
directive=0
|
|
577
|
+
fi
|
|
578
|
+
|
|
579
|
+
__${t2}_debug "directive: \${directive}"
|
|
580
|
+
__${t2}_debug "completions: \${out}"
|
|
581
|
+
__${t2}_debug "flagPrefix: \${flagPrefix}"
|
|
582
|
+
|
|
583
|
+
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
|
584
|
+
__${t2}_debug "Completion received error. Ignoring completions."
|
|
585
|
+
return
|
|
586
|
+
fi
|
|
587
|
+
|
|
588
|
+
local activeHelpMarker="%"
|
|
589
|
+
local endIndex=\${#activeHelpMarker}
|
|
590
|
+
local startIndex=$((\${#activeHelpMarker}+1))
|
|
591
|
+
local hasActiveHelp=0
|
|
592
|
+
while IFS='
|
|
593
|
+
' read -r comp; do
|
|
594
|
+
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
595
|
+
if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
596
|
+
__${t2}_debug "ActiveHelp found: $comp"
|
|
597
|
+
comp="\${comp[$startIndex,-1]}"
|
|
598
|
+
if [ -n "$comp" ]; then
|
|
599
|
+
compadd -x "\${comp}"
|
|
600
|
+
__${t2}_debug "ActiveHelp will need delimiter"
|
|
601
|
+
hasActiveHelp=1
|
|
602
|
+
fi
|
|
603
|
+
continue
|
|
604
|
+
fi
|
|
605
|
+
|
|
606
|
+
if [ -n "$comp" ]; then
|
|
607
|
+
# If requested, completions are returned with a description.
|
|
608
|
+
# The description is preceded by a TAB character.
|
|
609
|
+
# For zsh's _describe, we need to use a : instead of a TAB.
|
|
610
|
+
# We first need to escape any : as part of the completion itself.
|
|
611
|
+
comp=\${comp//:/\\:}
|
|
612
|
+
|
|
613
|
+
local tab="$(printf '\\t')"
|
|
614
|
+
comp=\${comp//$tab/:}
|
|
615
|
+
|
|
616
|
+
__${t2}_debug "Adding completion: \${comp}"
|
|
617
|
+
completions+=\${comp}
|
|
618
|
+
lastComp=$comp
|
|
619
|
+
fi
|
|
620
|
+
done < <(printf "%s
|
|
621
|
+
" "\${out[@]}")
|
|
622
|
+
|
|
623
|
+
# Add a delimiter after the activeHelp statements, but only if:
|
|
624
|
+
# - there are completions following the activeHelp statements, or
|
|
625
|
+
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
626
|
+
if [ $hasActiveHelp -eq 1 ]; then
|
|
627
|
+
if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
628
|
+
__${t2}_debug "Adding activeHelp delimiter"
|
|
629
|
+
compadd -x "--"
|
|
630
|
+
hasActiveHelp=0
|
|
631
|
+
fi
|
|
632
|
+
fi
|
|
633
|
+
|
|
634
|
+
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
|
635
|
+
__${t2}_debug "Activating nospace."
|
|
636
|
+
noSpace="-S ''"
|
|
637
|
+
fi
|
|
638
|
+
|
|
639
|
+
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
640
|
+
__${t2}_debug "Activating keep order."
|
|
641
|
+
keepOrder="-V"
|
|
642
|
+
fi
|
|
643
|
+
|
|
644
|
+
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
|
645
|
+
# File extension filtering
|
|
646
|
+
local filteringCmd
|
|
647
|
+
filteringCmd='_files'
|
|
648
|
+
for filter in \${completions[@]}; do
|
|
649
|
+
if [ \${filter[1]} != '*' ]; then
|
|
650
|
+
# zsh requires a glob pattern to do file filtering
|
|
651
|
+
filter="\\*.$filter"
|
|
652
|
+
fi
|
|
653
|
+
filteringCmd+=" -g $filter"
|
|
654
|
+
done
|
|
655
|
+
filteringCmd+=" \${flagPrefix}"
|
|
656
|
+
|
|
657
|
+
__${t2}_debug "File filtering command: $filteringCmd"
|
|
658
|
+
_arguments '*:filename:'"$filteringCmd"
|
|
659
|
+
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
|
660
|
+
# File completion for directories only
|
|
661
|
+
local subdir
|
|
662
|
+
subdir="\${completions[1]}"
|
|
663
|
+
if [ -n "$subdir" ]; then
|
|
664
|
+
__${t2}_debug "Listing directories in $subdir"
|
|
665
|
+
pushd "\${subdir}" >/dev/null 2>&1
|
|
666
|
+
else
|
|
667
|
+
__${t2}_debug "Listing directories in ."
|
|
668
|
+
fi
|
|
669
|
+
|
|
670
|
+
local result
|
|
671
|
+
_arguments '*:dirname:_files -/'" \${flagPrefix}"
|
|
672
|
+
result=$?
|
|
673
|
+
if [ -n "$subdir" ]; then
|
|
674
|
+
popd >/dev/null 2>&1
|
|
675
|
+
fi
|
|
676
|
+
return $result
|
|
677
|
+
else
|
|
678
|
+
__${t2}_debug "Calling _describe"
|
|
679
|
+
if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
|
|
680
|
+
__${t2}_debug "_describe found some completions"
|
|
681
|
+
|
|
682
|
+
# Return the success of having called _describe
|
|
683
|
+
return 0
|
|
684
|
+
else
|
|
685
|
+
__${t2}_debug "_describe did not find completions."
|
|
686
|
+
__${t2}_debug "Checking if we should do file completion."
|
|
687
|
+
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
|
688
|
+
__${t2}_debug "deactivating file completion"
|
|
689
|
+
|
|
690
|
+
# Return 0 to indicate completion is finished and prevent zsh from
|
|
691
|
+
# trying other completion algorithms (which could cause hanging).
|
|
692
|
+
# We use NoFileComp directive to explicitly disable file completion.
|
|
693
|
+
return 0
|
|
694
|
+
else
|
|
695
|
+
# Perform file completion
|
|
696
|
+
__${t2}_debug "Activating file completion"
|
|
697
|
+
|
|
698
|
+
# We must return the result of this command, so it must be the
|
|
699
|
+
# last command, or else we must store its result to return it.
|
|
700
|
+
_arguments '*:filename:_files'" \${flagPrefix}"
|
|
701
|
+
fi
|
|
702
|
+
fi
|
|
703
|
+
fi
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
# don't run the completion function when being sourced or eval-ed
|
|
707
|
+
if [ "\${funcstack[1]}" = "_${t2}" ]; then
|
|
708
|
+
_${t2}
|
|
709
|
+
fi
|
|
710
|
+
`;
|
|
711
|
+
}
|
|
712
|
+
__name(t, "t");
|
|
713
|
+
function n(t2, n2) {
|
|
714
|
+
let r2 = t2.replace(/[-:]/g, `_`);
|
|
715
|
+
return `# bash completion for ${t2}
|
|
716
|
+
|
|
717
|
+
# Define shell completion directives
|
|
718
|
+
readonly ShellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
719
|
+
readonly ShellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
720
|
+
readonly ShellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
721
|
+
readonly ShellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
722
|
+
readonly ShellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
723
|
+
readonly ShellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
724
|
+
|
|
725
|
+
# Function to debug completion
|
|
726
|
+
__${r2}_debug() {
|
|
727
|
+
if [[ -n \${BASH_COMP_DEBUG_FILE:-} ]]; then
|
|
728
|
+
echo "$*" >> "\${BASH_COMP_DEBUG_FILE}"
|
|
729
|
+
fi
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
# Function to handle completions
|
|
733
|
+
__${r2}_complete() {
|
|
734
|
+
local cur prev words cword
|
|
735
|
+
_get_comp_words_by_ref -n "=:" cur prev words cword
|
|
736
|
+
|
|
737
|
+
local requestComp out directive
|
|
738
|
+
|
|
739
|
+
# Build the command to get completions
|
|
740
|
+
requestComp="${n2} complete -- \${words[@]:1}"
|
|
741
|
+
|
|
742
|
+
# Add an empty parameter if the last parameter is complete
|
|
743
|
+
if [[ -z "$cur" ]]; then
|
|
744
|
+
requestComp="$requestComp ''"
|
|
745
|
+
fi
|
|
746
|
+
|
|
747
|
+
# Get completions from the program
|
|
748
|
+
out=$(eval "$requestComp" 2>/dev/null)
|
|
749
|
+
|
|
750
|
+
# Extract directive if present
|
|
751
|
+
directive=0
|
|
752
|
+
if [[ "$out" == *:* ]]; then
|
|
753
|
+
directive=\${out##*:}
|
|
754
|
+
out=\${out%:*}
|
|
755
|
+
fi
|
|
756
|
+
|
|
757
|
+
# Process completions based on directive
|
|
758
|
+
if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then
|
|
759
|
+
# Error, no completion
|
|
760
|
+
return
|
|
761
|
+
fi
|
|
762
|
+
|
|
763
|
+
# Apply directives
|
|
764
|
+
if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then
|
|
765
|
+
compopt -o nospace
|
|
766
|
+
fi
|
|
767
|
+
if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then
|
|
768
|
+
compopt -o nosort
|
|
769
|
+
fi
|
|
770
|
+
if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then
|
|
771
|
+
compopt +o default
|
|
772
|
+
fi
|
|
773
|
+
|
|
774
|
+
# Handle file extension filtering
|
|
775
|
+
if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then
|
|
776
|
+
local filter=""
|
|
777
|
+
for ext in $out; do
|
|
778
|
+
filter="$filter|$ext"
|
|
779
|
+
done
|
|
780
|
+
filter="\\.($filter)"
|
|
781
|
+
compopt -o filenames
|
|
782
|
+
COMPREPLY=( $(compgen -f -X "!$filter" -- "$cur") )
|
|
783
|
+
return
|
|
784
|
+
fi
|
|
785
|
+
|
|
786
|
+
# Handle directory filtering
|
|
787
|
+
if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then
|
|
788
|
+
compopt -o dirnames
|
|
789
|
+
COMPREPLY=( $(compgen -d -- "$cur") )
|
|
790
|
+
return
|
|
791
|
+
fi
|
|
792
|
+
|
|
793
|
+
# Process completions
|
|
794
|
+
local IFS=$'\\n'
|
|
795
|
+
local tab=$(printf '\\t')
|
|
796
|
+
|
|
797
|
+
# Parse completions with descriptions
|
|
798
|
+
local completions=()
|
|
799
|
+
while read -r comp; do
|
|
800
|
+
if [[ "$comp" == *$tab* ]]; then
|
|
801
|
+
# Split completion and description
|
|
802
|
+
local value=\${comp%%$tab*}
|
|
803
|
+
local desc=\${comp#*$tab}
|
|
804
|
+
completions+=("$value")
|
|
805
|
+
else
|
|
806
|
+
completions+=("$comp")
|
|
807
|
+
fi
|
|
808
|
+
done <<< "$out"
|
|
809
|
+
|
|
810
|
+
# Return completions
|
|
811
|
+
COMPREPLY=( $(compgen -W "\${completions[*]}" -- "$cur") )
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
# Register completion function
|
|
815
|
+
complete -F __${r2}_complete ${t2}
|
|
816
|
+
`;
|
|
817
|
+
}
|
|
818
|
+
__name(n, "n");
|
|
819
|
+
function r(t2, n2) {
|
|
820
|
+
let r2 = t2.replace(/[-:]/g, `_`), i3 = a.ShellCompDirectiveError, a2 = a.ShellCompDirectiveNoSpace, o2 = a.ShellCompDirectiveNoFileComp, s2 = a.ShellCompDirectiveFilterFileExt, c2 = a.ShellCompDirectiveFilterDirs;
|
|
821
|
+
return `# fish completion for ${t2} -*- shell-script -*-
|
|
822
|
+
|
|
823
|
+
function __${r2}_debug
|
|
824
|
+
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
825
|
+
if test -n "$file"
|
|
826
|
+
echo "$argv" >> $file
|
|
827
|
+
end
|
|
828
|
+
end
|
|
829
|
+
|
|
830
|
+
function __${r2}_perform_completion
|
|
831
|
+
__${r2}_debug "Starting __${r2}_perform_completion"
|
|
832
|
+
|
|
833
|
+
# Extract all args except the last one
|
|
834
|
+
set -l args (commandline -opc)
|
|
835
|
+
# Extract the last arg and escape it in case it is a space or wildcard
|
|
836
|
+
set -l lastArg (string escape -- (commandline -ct))
|
|
837
|
+
|
|
838
|
+
__${r2}_debug "args: $args"
|
|
839
|
+
__${r2}_debug "last arg: $lastArg"
|
|
840
|
+
|
|
841
|
+
# Build the completion request command
|
|
842
|
+
set -l requestComp "${n2} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
|
|
843
|
+
|
|
844
|
+
__${r2}_debug "Calling $requestComp"
|
|
845
|
+
set -l results (eval $requestComp 2> /dev/null)
|
|
846
|
+
|
|
847
|
+
# Some programs may output extra empty lines after the directive.
|
|
848
|
+
# Let's ignore them or else it will break completion.
|
|
849
|
+
# Ref: https://github.com/spf13/cobra/issues/1279
|
|
850
|
+
for line in $results[-1..1]
|
|
851
|
+
if test (string trim -- $line) = ""
|
|
852
|
+
# Found an empty line, remove it
|
|
853
|
+
set results $results[1..-2]
|
|
854
|
+
else
|
|
855
|
+
# Found non-empty line, we have our proper output
|
|
856
|
+
break
|
|
857
|
+
end
|
|
858
|
+
end
|
|
859
|
+
|
|
860
|
+
set -l comps $results[1..-2]
|
|
861
|
+
set -l directiveLine $results[-1]
|
|
862
|
+
|
|
863
|
+
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
|
|
864
|
+
# completions must be prefixed with the flag
|
|
865
|
+
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
|
|
866
|
+
|
|
867
|
+
__${r2}_debug "Comps: $comps"
|
|
868
|
+
__${r2}_debug "DirectiveLine: $directiveLine"
|
|
869
|
+
__${r2}_debug "flagPrefix: $flagPrefix"
|
|
870
|
+
|
|
871
|
+
for comp in $comps
|
|
872
|
+
printf "%s%s\\n" "$flagPrefix" "$comp"
|
|
873
|
+
end
|
|
874
|
+
|
|
875
|
+
printf "%s\\n" "$directiveLine"
|
|
876
|
+
end
|
|
877
|
+
|
|
878
|
+
# This function limits calls to __${r2}_perform_completion, by caching the result
|
|
879
|
+
function __${r2}_perform_completion_once
|
|
880
|
+
__${r2}_debug "Starting __${r2}_perform_completion_once"
|
|
881
|
+
|
|
882
|
+
if test -n "$__${r2}_perform_completion_once_result"
|
|
883
|
+
__${r2}_debug "Seems like a valid result already exists, skipping __${r2}_perform_completion"
|
|
884
|
+
return 0
|
|
885
|
+
end
|
|
886
|
+
|
|
887
|
+
set --global __${r2}_perform_completion_once_result (__${r2}_perform_completion)
|
|
888
|
+
if test -z "$__${r2}_perform_completion_once_result"
|
|
889
|
+
__${r2}_debug "No completions, probably due to a failure"
|
|
890
|
+
return 1
|
|
891
|
+
end
|
|
892
|
+
|
|
893
|
+
__${r2}_debug "Performed completions and set __${r2}_perform_completion_once_result"
|
|
894
|
+
return 0
|
|
895
|
+
end
|
|
896
|
+
|
|
897
|
+
# This function is used to clear the cached result after completions are run
|
|
898
|
+
function __${r2}_clear_perform_completion_once_result
|
|
899
|
+
__${r2}_debug ""
|
|
900
|
+
__${r2}_debug "========= clearing previously set __${r2}_perform_completion_once_result variable =========="
|
|
901
|
+
set --erase __${r2}_perform_completion_once_result
|
|
902
|
+
__${r2}_debug "Successfully erased the variable __${r2}_perform_completion_once_result"
|
|
903
|
+
end
|
|
904
|
+
|
|
905
|
+
function __${r2}_requires_order_preservation
|
|
906
|
+
__${r2}_debug ""
|
|
907
|
+
__${r2}_debug "========= checking if order preservation is required =========="
|
|
908
|
+
|
|
909
|
+
__${r2}_perform_completion_once
|
|
910
|
+
if test -z "$__${r2}_perform_completion_once_result"
|
|
911
|
+
__${r2}_debug "Error determining if order preservation is required"
|
|
912
|
+
return 1
|
|
913
|
+
end
|
|
914
|
+
|
|
915
|
+
set -l directive (string sub --start 2 $__${r2}_perform_completion_once_result[-1])
|
|
916
|
+
__${r2}_debug "Directive is: $directive"
|
|
917
|
+
|
|
918
|
+
set -l shellCompDirectiveKeepOrder ${a.ShellCompDirectiveKeepOrder}
|
|
919
|
+
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
|
|
920
|
+
__${r2}_debug "Keeporder is: $keeporder"
|
|
921
|
+
|
|
922
|
+
if test $keeporder -ne 0
|
|
923
|
+
__${r2}_debug "This does require order preservation"
|
|
924
|
+
return 0
|
|
925
|
+
end
|
|
926
|
+
|
|
927
|
+
__${r2}_debug "This doesn't require order preservation"
|
|
928
|
+
return 1
|
|
929
|
+
end
|
|
930
|
+
|
|
931
|
+
# This function does two things:
|
|
932
|
+
# - Obtain the completions and store them in the global __${r2}_comp_results
|
|
933
|
+
# - Return false if file completion should be performed
|
|
934
|
+
function __${r2}_prepare_completions
|
|
935
|
+
__${r2}_debug ""
|
|
936
|
+
__${r2}_debug "========= starting completion logic =========="
|
|
937
|
+
|
|
938
|
+
# Start fresh
|
|
939
|
+
set --erase __${r2}_comp_results
|
|
940
|
+
|
|
941
|
+
__${r2}_perform_completion_once
|
|
942
|
+
__${r2}_debug "Completion results: $__${r2}_perform_completion_once_result"
|
|
943
|
+
|
|
944
|
+
if test -z "$__${r2}_perform_completion_once_result"
|
|
945
|
+
__${r2}_debug "No completion, probably due to a failure"
|
|
946
|
+
# Might as well do file completion, in case it helps
|
|
947
|
+
return 1
|
|
948
|
+
end
|
|
949
|
+
|
|
950
|
+
set -l directive (string sub --start 2 $__${r2}_perform_completion_once_result[-1])
|
|
951
|
+
set --global __${r2}_comp_results $__${r2}_perform_completion_once_result[1..-2]
|
|
952
|
+
|
|
953
|
+
__${r2}_debug "Completions are: $__${r2}_comp_results"
|
|
954
|
+
__${r2}_debug "Directive is: $directive"
|
|
955
|
+
|
|
956
|
+
set -l shellCompDirectiveError ${i3}
|
|
957
|
+
set -l shellCompDirectiveNoSpace ${a2}
|
|
958
|
+
set -l shellCompDirectiveNoFileComp ${o2}
|
|
959
|
+
set -l shellCompDirectiveFilterFileExt ${s2}
|
|
960
|
+
set -l shellCompDirectiveFilterDirs ${c2}
|
|
961
|
+
|
|
962
|
+
if test -z "$directive"
|
|
963
|
+
set directive 0
|
|
964
|
+
end
|
|
965
|
+
|
|
966
|
+
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
|
|
967
|
+
if test $compErr -eq 1
|
|
968
|
+
__${r2}_debug "Received error directive: aborting."
|
|
969
|
+
# Might as well do file completion, in case it helps
|
|
970
|
+
return 1
|
|
971
|
+
end
|
|
972
|
+
|
|
973
|
+
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
|
|
974
|
+
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
|
|
975
|
+
if test $filefilter -eq 1; or test $dirfilter -eq 1
|
|
976
|
+
__${r2}_debug "File extension filtering or directory filtering not supported"
|
|
977
|
+
# Do full file completion instead
|
|
978
|
+
return 1
|
|
979
|
+
end
|
|
980
|
+
|
|
981
|
+
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
|
|
982
|
+
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
|
|
983
|
+
|
|
984
|
+
__${r2}_debug "nospace: $nospace, nofiles: $nofiles"
|
|
985
|
+
|
|
986
|
+
# If we want to prevent a space, or if file completion is NOT disabled,
|
|
987
|
+
# we need to count the number of valid completions.
|
|
988
|
+
# To do so, we will filter on prefix as the completions we have received
|
|
989
|
+
# may not already be filtered so as to allow fish to match on different
|
|
990
|
+
# criteria than the prefix.
|
|
991
|
+
if test $nospace -ne 0; or test $nofiles -eq 0
|
|
992
|
+
set -l prefix (commandline -t | string escape --style=regex)
|
|
993
|
+
__${r2}_debug "prefix: $prefix"
|
|
994
|
+
|
|
995
|
+
set -l completions (string match -r -- "^$prefix.*" $__${r2}_comp_results)
|
|
996
|
+
set --global __${r2}_comp_results $completions
|
|
997
|
+
__${r2}_debug "Filtered completions are: $__${r2}_comp_results"
|
|
998
|
+
|
|
999
|
+
# Important not to quote the variable for count to work
|
|
1000
|
+
set -l numComps (count $__${r2}_comp_results)
|
|
1001
|
+
__${r2}_debug "numComps: $numComps"
|
|
1002
|
+
|
|
1003
|
+
if test $numComps -eq 1; and test $nospace -ne 0
|
|
1004
|
+
# We must first split on \\t to get rid of the descriptions to be
|
|
1005
|
+
# able to check what the actual completion will be.
|
|
1006
|
+
# We don't need descriptions anyway since there is only a single
|
|
1007
|
+
# real completion which the shell will expand immediately.
|
|
1008
|
+
set -l split (string split --max 1 "\\t" $__${r2}_comp_results[1])
|
|
1009
|
+
|
|
1010
|
+
# Fish won't add a space if the completion ends with any
|
|
1011
|
+
# of the following characters: @=/:.,
|
|
1012
|
+
set -l lastChar (string sub -s -1 -- $split)
|
|
1013
|
+
if not string match -r -q "[@=/:.,]" -- "$lastChar"
|
|
1014
|
+
# In other cases, to support the "nospace" directive we trick the shell
|
|
1015
|
+
# by outputting an extra, longer completion.
|
|
1016
|
+
__${r2}_debug "Adding second completion to perform nospace directive"
|
|
1017
|
+
set --global __${r2}_comp_results $split[1] $split[1].
|
|
1018
|
+
__${r2}_debug "Completions are now: $__${r2}_comp_results"
|
|
1019
|
+
end
|
|
1020
|
+
end
|
|
1021
|
+
|
|
1022
|
+
if test $numComps -eq 0; and test $nofiles -eq 0
|
|
1023
|
+
# To be consistent with bash and zsh, we only trigger file
|
|
1024
|
+
# completion when there are no other completions
|
|
1025
|
+
__${r2}_debug "Requesting file completion"
|
|
1026
|
+
return 1
|
|
1027
|
+
end
|
|
1028
|
+
end
|
|
1029
|
+
|
|
1030
|
+
return 0
|
|
1031
|
+
end
|
|
1032
|
+
|
|
1033
|
+
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
|
|
1034
|
+
# so we can properly delete any completions provided by another script.
|
|
1035
|
+
# Only do this if the program can be found, or else fish may print some errors; besides,
|
|
1036
|
+
# the existing completions will only be loaded if the program can be found.
|
|
1037
|
+
if type -q "${t2}"
|
|
1038
|
+
# The space after the program name is essential to trigger completion for the program
|
|
1039
|
+
# and not completion of the program name itself.
|
|
1040
|
+
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
|
|
1041
|
+
complete --do-complete "${t2} " > /dev/null 2>&1
|
|
1042
|
+
end
|
|
1043
|
+
|
|
1044
|
+
# Remove any pre-existing completions for the program since we will be handling all of them.
|
|
1045
|
+
complete -c ${t2} -e
|
|
1046
|
+
|
|
1047
|
+
# This will get called after the two calls below and clear the cached result
|
|
1048
|
+
complete -c ${t2} -n '__${r2}_clear_perform_completion_once_result'
|
|
1049
|
+
# The call to __${r2}_prepare_completions will setup __${r2}_comp_results
|
|
1050
|
+
# which provides the program's completion choices.
|
|
1051
|
+
# If this doesn't require order preservation, we don't use the -k flag
|
|
1052
|
+
complete -c ${t2} -n 'not __${r2}_requires_order_preservation && __${r2}_prepare_completions' -f -a '$__${r2}_comp_results'
|
|
1053
|
+
# Otherwise we use the -k flag
|
|
1054
|
+
complete -k -c ${t2} -n '__${r2}_requires_order_preservation && __${r2}_prepare_completions' -f -a '$__${r2}_comp_results'
|
|
1055
|
+
`;
|
|
1056
|
+
}
|
|
1057
|
+
__name(r, "r");
|
|
1058
|
+
function i(t2, n2) {
|
|
1059
|
+
let r2 = t2.replace(/[-:]/g, `_`);
|
|
1060
|
+
return `# powershell completion for ${t2} -*- shell-script -*-
|
|
1061
|
+
|
|
1062
|
+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
1063
|
+
function __${t2}_debug {
|
|
1064
|
+
if ($env:BASH_COMP_DEBUG_FILE) {
|
|
1065
|
+
"$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
filter __${t2}_escapeStringWithSpecialChars {
|
|
1070
|
+
$_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\`$&'
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
[scriptblock]$__${r2}CompleterBlock = {
|
|
1074
|
+
param(
|
|
1075
|
+
$WordToComplete,
|
|
1076
|
+
$CommandAst,
|
|
1077
|
+
$CursorPosition
|
|
1078
|
+
)
|
|
1079
|
+
|
|
1080
|
+
# Get the current command line and convert into a string
|
|
1081
|
+
$Command = $CommandAst.CommandElements
|
|
1082
|
+
$Command = "$Command"
|
|
1083
|
+
|
|
1084
|
+
__${t2}_debug ""
|
|
1085
|
+
__${t2}_debug "========= starting completion logic =========="
|
|
1086
|
+
__${t2}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
|
|
1087
|
+
|
|
1088
|
+
# The user could have moved the cursor backwards on the command-line.
|
|
1089
|
+
# We need to trigger completion from the $CursorPosition location, so we need
|
|
1090
|
+
# to truncate the command-line ($Command) up to the $CursorPosition location.
|
|
1091
|
+
# Make sure the $Command is longer then the $CursorPosition before we truncate.
|
|
1092
|
+
# This happens because the $Command does not include the last space.
|
|
1093
|
+
if ($Command.Length -gt $CursorPosition) {
|
|
1094
|
+
$Command = $Command.Substring(0, $CursorPosition)
|
|
1095
|
+
}
|
|
1096
|
+
__${t2}_debug "Truncated command: $Command"
|
|
1097
|
+
|
|
1098
|
+
$ShellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
1099
|
+
$ShellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
1100
|
+
$ShellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
1101
|
+
$ShellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
1102
|
+
$ShellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
1103
|
+
$ShellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
1104
|
+
|
|
1105
|
+
# Prepare the command to request completions for the program.
|
|
1106
|
+
# Split the command at the first space to separate the program and arguments.
|
|
1107
|
+
$Program, $Arguments = $Command.Split(" ", 2)
|
|
1108
|
+
|
|
1109
|
+
$QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
|
|
1110
|
+
__${t2}_debug "QuotedArgs: $QuotedArgs"
|
|
1111
|
+
|
|
1112
|
+
$RequestComp = "& ${n2} complete '--' $QuotedArgs"
|
|
1113
|
+
__${t2}_debug "RequestComp: $RequestComp"
|
|
1114
|
+
|
|
1115
|
+
# we cannot use $WordToComplete because it
|
|
1116
|
+
# has the wrong values if the cursor was moved
|
|
1117
|
+
# so use the last argument
|
|
1118
|
+
if ($WordToComplete -ne "" ) {
|
|
1119
|
+
$WordToComplete = $Arguments.Split(" ")[-1]
|
|
1120
|
+
}
|
|
1121
|
+
__${t2}_debug "New WordToComplete: $WordToComplete"
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
# Check for flag with equal sign
|
|
1125
|
+
$IsEqualFlag = ($WordToComplete -Like "--*=*" )
|
|
1126
|
+
if ( $IsEqualFlag ) {
|
|
1127
|
+
__${t2}_debug "Completing equal sign flag"
|
|
1128
|
+
# Remove the flag part
|
|
1129
|
+
$Flag, $WordToComplete = $WordToComplete.Split("=", 2)
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
|
|
1133
|
+
# If the last parameter is complete (there is a space following it)
|
|
1134
|
+
# We add an extra empty parameter so we can indicate this to the go method.
|
|
1135
|
+
__${t2}_debug "Adding extra empty parameter"
|
|
1136
|
+
# PowerShell 7.2+ changed the way how the arguments are passed to executables,
|
|
1137
|
+
# so for pre-7.2 or when Legacy argument passing is enabled we need to use
|
|
1138
|
+
if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
|
|
1139
|
+
($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or
|
|
1140
|
+
(($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and
|
|
1141
|
+
$PSNativeCommandArgumentPassing -eq 'Legacy')) {
|
|
1142
|
+
$RequestComp="$RequestComp" + ' \`"\`"'
|
|
1143
|
+
} else {
|
|
1144
|
+
$RequestComp = "$RequestComp" + ' ""'
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
__${t2}_debug "Calling $RequestComp"
|
|
1149
|
+
# First disable ActiveHelp which is not supported for Powershell
|
|
1150
|
+
$env:ActiveHelp = 0
|
|
1151
|
+
|
|
1152
|
+
# call the command store the output in $out and redirect stderr and stdout to null
|
|
1153
|
+
# $Out is an array contains each line per element
|
|
1154
|
+
Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
|
|
1155
|
+
|
|
1156
|
+
# get directive from last line
|
|
1157
|
+
[int]$Directive = $Out[-1].TrimStart(':')
|
|
1158
|
+
if ($Directive -eq "") {
|
|
1159
|
+
# There is no directive specified
|
|
1160
|
+
$Directive = 0
|
|
1161
|
+
}
|
|
1162
|
+
__${t2}_debug "The completion directive is: $Directive"
|
|
1163
|
+
|
|
1164
|
+
# remove directive (last element) from out
|
|
1165
|
+
$Out = $Out | Where-Object { $_ -ne $Out[-1] }
|
|
1166
|
+
__${t2}_debug "The completions are: $Out"
|
|
1167
|
+
|
|
1168
|
+
if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
|
|
1169
|
+
# Error code. No completion.
|
|
1170
|
+
__${t2}_debug "Received error from custom completion go code"
|
|
1171
|
+
return
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
$Longest = 0
|
|
1175
|
+
[Array]$Values = $Out | ForEach-Object {
|
|
1176
|
+
# Split the output in name and description
|
|
1177
|
+
$Name, $Description = $_.Split("\`t", 2)
|
|
1178
|
+
__${t2}_debug "Name: $Name Description: $Description"
|
|
1179
|
+
|
|
1180
|
+
# Look for the longest completion so that we can format things nicely
|
|
1181
|
+
if ($Longest -lt $Name.Length) {
|
|
1182
|
+
$Longest = $Name.Length
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
# Set the description to a one space string if there is none set.
|
|
1186
|
+
# This is needed because the CompletionResult does not accept an empty string as argument
|
|
1187
|
+
if (-Not $Description) {
|
|
1188
|
+
$Description = " "
|
|
1189
|
+
}
|
|
1190
|
+
@{ Name = "$Name"; Description = "$Description" }
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
$Space = " "
|
|
1195
|
+
if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
|
|
1196
|
+
# remove the space here
|
|
1197
|
+
__${t2}_debug "ShellCompDirectiveNoSpace is called"
|
|
1198
|
+
$Space = ""
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
|
|
1202
|
+
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
|
|
1203
|
+
__${t2}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
|
|
1204
|
+
|
|
1205
|
+
# return here to prevent the completion of the extensions
|
|
1206
|
+
return
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
$Values = $Values | Where-Object {
|
|
1210
|
+
# filter the result
|
|
1211
|
+
$_.Name -like "$WordToComplete*"
|
|
1212
|
+
|
|
1213
|
+
# Join the flag back if we have an equal sign flag
|
|
1214
|
+
if ( $IsEqualFlag ) {
|
|
1215
|
+
__${t2}_debug "Join the equal sign flag back to the completion value"
|
|
1216
|
+
$_.Name = $Flag + "=" + $_.Name
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
# we sort the values in ascending order by name if keep order isn't passed
|
|
1221
|
+
if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {
|
|
1222
|
+
$Values = $Values | Sort-Object -Property Name
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
|
|
1226
|
+
__${t2}_debug "ShellCompDirectiveNoFileComp is called"
|
|
1227
|
+
|
|
1228
|
+
if ($Values.Length -eq 0) {
|
|
1229
|
+
# Just print an empty string here so the
|
|
1230
|
+
# shell does not start to complete paths.
|
|
1231
|
+
# We cannot use CompletionResult here because
|
|
1232
|
+
# it does not accept an empty string as argument.
|
|
1233
|
+
""
|
|
1234
|
+
return
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
# Get the current mode
|
|
1239
|
+
$Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
|
|
1240
|
+
__${t2}_debug "Mode: $Mode"
|
|
1241
|
+
|
|
1242
|
+
$Values | ForEach-Object {
|
|
1243
|
+
|
|
1244
|
+
# store temporary because switch will overwrite $_
|
|
1245
|
+
$comp = $_
|
|
1246
|
+
|
|
1247
|
+
# PowerShell supports three different completion modes
|
|
1248
|
+
# - TabCompleteNext (default windows style - on each key press the next option is displayed)
|
|
1249
|
+
# - Complete (works like bash)
|
|
1250
|
+
# - MenuComplete (works like zsh)
|
|
1251
|
+
# You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
|
|
1252
|
+
|
|
1253
|
+
# CompletionResult Arguments:
|
|
1254
|
+
# 1) CompletionText text to be used as the auto completion result
|
|
1255
|
+
# 2) ListItemText text to be displayed in the suggestion list
|
|
1256
|
+
# 3) ResultType type of completion result
|
|
1257
|
+
# 4) ToolTip text for the tooltip with details about the object
|
|
1258
|
+
|
|
1259
|
+
switch ($Mode) {
|
|
1260
|
+
|
|
1261
|
+
# bash like
|
|
1262
|
+
"Complete" {
|
|
1263
|
+
|
|
1264
|
+
if ($Values.Length -eq 1) {
|
|
1265
|
+
__${t2}_debug "Only one completion left"
|
|
1266
|
+
|
|
1267
|
+
# insert space after value
|
|
1268
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${t2}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
1269
|
+
|
|
1270
|
+
} else {
|
|
1271
|
+
# Add the proper number of spaces to align the descriptions
|
|
1272
|
+
while($comp.Name.Length -lt $Longest) {
|
|
1273
|
+
$comp.Name = $comp.Name + " "
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
# Check for empty description and only add parentheses if needed
|
|
1277
|
+
if ($($comp.Description) -eq " " ) {
|
|
1278
|
+
$Description = ""
|
|
1279
|
+
} else {
|
|
1280
|
+
$Description = " ($($comp.Description))"
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
[System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
# zsh like
|
|
1288
|
+
"MenuComplete" {
|
|
1289
|
+
# insert space after value
|
|
1290
|
+
# MenuComplete will automatically show the ToolTip of
|
|
1291
|
+
# the highlighted value at the bottom of the suggestions.
|
|
1292
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${t2}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
# TabCompleteNext and in case we get something unknown
|
|
1296
|
+
Default {
|
|
1297
|
+
# Like MenuComplete but we don't want to add a space here because
|
|
1298
|
+
# the user need to press space anyway to get the completion.
|
|
1299
|
+
# Description will not be shown because that's not possible with TabCompleteNext
|
|
1300
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${t2}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
Register-ArgumentCompleter -CommandName '${t2}' -ScriptBlock $__${r2}CompleterBlock
|
|
1308
|
+
`;
|
|
1309
|
+
}
|
|
1310
|
+
__name(i, "i");
|
|
1311
|
+
var a = { ShellCompDirectiveError: 1, ShellCompDirectiveNoSpace: 2, ShellCompDirectiveNoFileComp: 4, ShellCompDirectiveFilterFileExt: 8, ShellCompDirectiveFilterDirs: 16, ShellCompDirectiveKeepOrder: 32, ShellCompDirectiveDefault: 0 };
|
|
1312
|
+
var o = class {
|
|
1313
|
+
static {
|
|
1314
|
+
__name(this, "o");
|
|
1315
|
+
}
|
|
1316
|
+
name;
|
|
1317
|
+
variadic;
|
|
1318
|
+
command;
|
|
1319
|
+
handler;
|
|
1320
|
+
constructor(e, t2, n2, r2 = false) {
|
|
1321
|
+
this.command = e, this.name = t2, this.handler = n2, this.variadic = r2;
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
var s = class {
|
|
1325
|
+
static {
|
|
1326
|
+
__name(this, "s");
|
|
1327
|
+
}
|
|
1328
|
+
value;
|
|
1329
|
+
description;
|
|
1330
|
+
command;
|
|
1331
|
+
handler;
|
|
1332
|
+
alias;
|
|
1333
|
+
isBoolean;
|
|
1334
|
+
constructor(e, t2, n2, r2, i3, a2) {
|
|
1335
|
+
this.command = e, this.value = t2, this.description = n2, this.handler = r2, this.alias = i3, this.isBoolean = a2;
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
var c = class {
|
|
1339
|
+
static {
|
|
1340
|
+
__name(this, "c");
|
|
1341
|
+
}
|
|
1342
|
+
value;
|
|
1343
|
+
description;
|
|
1344
|
+
options = /* @__PURE__ */ new Map();
|
|
1345
|
+
arguments = /* @__PURE__ */ new Map();
|
|
1346
|
+
parent;
|
|
1347
|
+
constructor(e, t2) {
|
|
1348
|
+
this.value = e, this.description = t2;
|
|
1349
|
+
}
|
|
1350
|
+
option(e, t2, n2, r2) {
|
|
1351
|
+
let i3, a2, o2;
|
|
1352
|
+
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);
|
|
1353
|
+
let c2 = new s(this, e, t2, i3, a2, o2);
|
|
1354
|
+
return this.options.set(e, c2), this;
|
|
1355
|
+
}
|
|
1356
|
+
argument(e, t2, n2 = false) {
|
|
1357
|
+
let r2 = new o(this, e, t2, n2);
|
|
1358
|
+
return this.arguments.set(e, r2), this;
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
var l = class extends c {
|
|
1362
|
+
static {
|
|
1363
|
+
__name(this, "l");
|
|
1364
|
+
}
|
|
1365
|
+
commands = /* @__PURE__ */ new Map();
|
|
1366
|
+
completions = [];
|
|
1367
|
+
directive = a.ShellCompDirectiveDefault;
|
|
1368
|
+
constructor() {
|
|
1369
|
+
super(``, ``);
|
|
1370
|
+
}
|
|
1371
|
+
command(e, t2) {
|
|
1372
|
+
let n2 = new c(e, t2);
|
|
1373
|
+
return this.commands.set(e, n2), n2;
|
|
1374
|
+
}
|
|
1375
|
+
stripOptions(e) {
|
|
1376
|
+
let t2 = [], n2 = 0;
|
|
1377
|
+
for (; n2 < e.length; ) {
|
|
1378
|
+
let r2 = e[n2];
|
|
1379
|
+
if (r2.startsWith(`-`)) {
|
|
1380
|
+
n2++;
|
|
1381
|
+
let t3 = false, i3 = this.findOption(this, r2);
|
|
1382
|
+
if (i3) t3 = i3.isBoolean ?? false;
|
|
1383
|
+
else for (let [, e2] of this.commands) {
|
|
1384
|
+
let n3 = this.findOption(e2, r2);
|
|
1385
|
+
if (n3) {
|
|
1386
|
+
t3 = n3.isBoolean ?? false;
|
|
1387
|
+
break;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
!t3 && n2 < e.length && !e[n2].startsWith(`-`) && n2++;
|
|
1391
|
+
} else t2.push(r2), n2++;
|
|
1392
|
+
}
|
|
1393
|
+
return t2;
|
|
1394
|
+
}
|
|
1395
|
+
matchCommand(e) {
|
|
1396
|
+
e = this.stripOptions(e);
|
|
1397
|
+
let t2 = [], n2 = [], r2 = null;
|
|
1398
|
+
for (let i3 = 0; i3 < e.length; i3++) {
|
|
1399
|
+
let a2 = e[i3];
|
|
1400
|
+
t2.push(a2);
|
|
1401
|
+
let o2 = this.commands.get(t2.join(` `));
|
|
1402
|
+
if (o2) r2 = o2;
|
|
1403
|
+
else {
|
|
1404
|
+
n2 = e.slice(i3, e.length);
|
|
1405
|
+
break;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
return [r2 || this, n2];
|
|
1409
|
+
}
|
|
1410
|
+
shouldCompleteFlags(e, t2) {
|
|
1411
|
+
if (t2.startsWith(`-`)) return true;
|
|
1412
|
+
if (e?.startsWith(`-`)) {
|
|
1413
|
+
let t3 = this.findOption(this, e);
|
|
1414
|
+
if (!t3) {
|
|
1415
|
+
for (let [, n2] of this.commands) if (t3 = this.findOption(n2, e), t3) break;
|
|
1416
|
+
}
|
|
1417
|
+
return !(t3 && t3.isBoolean);
|
|
1418
|
+
}
|
|
1419
|
+
return false;
|
|
1420
|
+
}
|
|
1421
|
+
shouldCompleteCommands(e) {
|
|
1422
|
+
return !e.startsWith(`-`);
|
|
1423
|
+
}
|
|
1424
|
+
handleFlagCompletion(e, t2, n2, r2) {
|
|
1425
|
+
let i3;
|
|
1426
|
+
if (n2.includes(`=`)) {
|
|
1427
|
+
let [e2] = n2.split(`=`);
|
|
1428
|
+
i3 = e2;
|
|
1429
|
+
} else if (r2?.startsWith(`-`)) {
|
|
1430
|
+
let t3 = this.findOption(e, r2);
|
|
1431
|
+
t3 && !t3.isBoolean && (i3 = r2);
|
|
1432
|
+
}
|
|
1433
|
+
if (i3) {
|
|
1434
|
+
let t3 = this.findOption(e, i3);
|
|
1435
|
+
if (t3?.handler) {
|
|
1436
|
+
let n3 = [];
|
|
1437
|
+
t3.handler.call(t3, (e2, t4) => n3.push({ value: e2, description: t4 }), e.options), this.completions = n3;
|
|
1438
|
+
}
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
if (n2.startsWith(`-`)) {
|
|
1442
|
+
let t3 = n2.startsWith(`-`) && !n2.startsWith(`--`), r3 = n2.replace(/^-+/, ``);
|
|
1443
|
+
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 });
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
findOption(e, t2) {
|
|
1447
|
+
let n2 = e.options.get(t2);
|
|
1448
|
+
if (n2 || (n2 = e.options.get(t2.replace(/^-+/, ``)), n2)) return n2;
|
|
1449
|
+
for (let [n3, r2] of e.options) if (r2.alias && `-${r2.alias}` === t2) return r2;
|
|
1450
|
+
}
|
|
1451
|
+
handleCommandCompletion(e, t2) {
|
|
1452
|
+
let n2 = this.stripOptions(e);
|
|
1453
|
+
for (let [e2, r2] of this.commands) {
|
|
1454
|
+
if (e2 === ``) continue;
|
|
1455
|
+
let i3 = e2.split(` `);
|
|
1456
|
+
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 });
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
handlePositionalCompletion(e, t2) {
|
|
1460
|
+
let n2 = this.stripOptions(t2), r2 = e.value.split(` `).length, i3 = Math.max(0, n2.length - r2), a2 = Array.from(e.arguments.entries());
|
|
1461
|
+
if (a2.length > 0) {
|
|
1462
|
+
let t3;
|
|
1463
|
+
if (i3 < a2.length) {
|
|
1464
|
+
let [e2, n3] = a2[i3];
|
|
1465
|
+
t3 = n3;
|
|
1466
|
+
} else {
|
|
1467
|
+
let e2 = a2[a2.length - 1][1];
|
|
1468
|
+
e2.variadic && (t3 = e2);
|
|
1469
|
+
}
|
|
1470
|
+
if (t3 && t3.handler && typeof t3.handler == `function`) {
|
|
1471
|
+
let n3 = [];
|
|
1472
|
+
t3.handler.call(t3, (e2, t4) => n3.push({ value: e2, description: t4 }), e.options), this.completions.push(...n3);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
complete(e) {
|
|
1477
|
+
this.directive = a.ShellCompDirectiveNoFileComp;
|
|
1478
|
+
let t2 = /* @__PURE__ */ new Set();
|
|
1479
|
+
this.completions.filter((e2) => t2.has(e2.value) ? false : (t2.add(e2.value), true)).filter((t3) => {
|
|
1480
|
+
if (e.includes(`=`)) {
|
|
1481
|
+
let [, n2] = e.split(`=`);
|
|
1482
|
+
return t3.value.startsWith(n2);
|
|
1483
|
+
}
|
|
1484
|
+
return t3.value.startsWith(e);
|
|
1485
|
+
}).forEach((e2) => console.log(`${e2.value} ${e2.description ?? ``}`)), console.log(`:${this.directive}`);
|
|
1486
|
+
}
|
|
1487
|
+
parse(e) {
|
|
1488
|
+
this.completions = [];
|
|
1489
|
+
let t2 = e[e.length - 1] === ``;
|
|
1490
|
+
t2 && e.pop();
|
|
1491
|
+
let n2 = e[e.length - 1] || ``, r2 = e.slice(0, -1);
|
|
1492
|
+
t2 && (n2 !== `` && r2.push(n2), n2 = ``);
|
|
1493
|
+
let [i3] = this.matchCommand(r2), a2 = r2[r2.length - 1];
|
|
1494
|
+
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);
|
|
1495
|
+
}
|
|
1496
|
+
setup(a2, o2, s2) {
|
|
1497
|
+
switch (i2(s2 === `zsh` || s2 === `bash` || s2 === `fish` || s2 === `powershell`, `Unsupported shell`), s2) {
|
|
1498
|
+
case `zsh`: {
|
|
1499
|
+
let t2 = t(a2, o2);
|
|
1500
|
+
console.log(t2);
|
|
1501
|
+
break;
|
|
1502
|
+
}
|
|
1503
|
+
case `bash`: {
|
|
1504
|
+
let e = n(a2, o2);
|
|
1505
|
+
console.log(e);
|
|
1506
|
+
break;
|
|
1507
|
+
}
|
|
1508
|
+
case `fish`: {
|
|
1509
|
+
let e = r(a2, o2);
|
|
1510
|
+
console.log(e);
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1513
|
+
case `powershell`: {
|
|
1514
|
+
let e = i(a2, o2);
|
|
1515
|
+
console.log(e);
|
|
1516
|
+
break;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
new l();
|
|
1522
|
+
|
|
1523
|
+
// ../../node_modules/.bun/@gunshi+plugin@0.32.0/node_modules/@gunshi/plugin/lib/index.js
|
|
1524
|
+
var ANONYMOUS_COMMAND_NAME = "(anonymous)";
|
|
1525
|
+
var NOOP = /* @__PURE__ */ __name(() => {
|
|
1526
|
+
}, "NOOP");
|
|
1527
|
+
var CLI_OPTIONS_DEFAULT = {
|
|
1528
|
+
name: void 0,
|
|
1529
|
+
description: void 0,
|
|
1530
|
+
version: void 0,
|
|
1531
|
+
cwd: void 0,
|
|
1532
|
+
usageSilent: false,
|
|
1533
|
+
subCommands: void 0,
|
|
1534
|
+
leftMargin: 2,
|
|
1535
|
+
middleMargin: 10,
|
|
1536
|
+
usageOptionType: false,
|
|
1537
|
+
usageOptionValue: true,
|
|
1538
|
+
renderHeader: void 0,
|
|
1539
|
+
renderUsage: void 0,
|
|
1540
|
+
renderValidationErrors: void 0,
|
|
1541
|
+
plugins: void 0,
|
|
1542
|
+
fallbackToEntry: false
|
|
1543
|
+
};
|
|
1544
|
+
function isLazyCommand(cmd) {
|
|
1545
|
+
return typeof cmd === "function" && "commandName" in cmd && !!cmd.commandName;
|
|
1546
|
+
}
|
|
1547
|
+
__name(isLazyCommand, "isLazyCommand");
|
|
1548
|
+
function create(obj = null) {
|
|
1549
|
+
return Object.create(obj);
|
|
1550
|
+
}
|
|
1551
|
+
__name(create, "create");
|
|
1552
|
+
function log(...args) {
|
|
1553
|
+
console.log(...args);
|
|
1554
|
+
}
|
|
1555
|
+
__name(log, "log");
|
|
1556
|
+
function deepFreeze(obj, ignores = []) {
|
|
1557
|
+
if (obj === null || typeof obj !== "object") return obj;
|
|
1558
|
+
for (const key of Object.keys(obj)) {
|
|
1559
|
+
const value = obj[key];
|
|
1560
|
+
if (ignores.includes(key)) continue;
|
|
1561
|
+
if (typeof value === "object" && value !== null) deepFreeze(value, ignores);
|
|
1562
|
+
}
|
|
1563
|
+
return Object.freeze(obj);
|
|
1564
|
+
}
|
|
1565
|
+
__name(deepFreeze, "deepFreeze");
|
|
1566
|
+
async function createCommandContext({ args = {}, explicit = {}, values = {}, positionals = [], rest = [], argv = [], tokens = [], command = {}, extensions = {}, cliOptions = {}, callMode = "entry", commandPath = [], omitted = false, validationError }) {
|
|
1567
|
+
const _args = Object.entries(args).reduce((acc, [key, value]) => {
|
|
1568
|
+
acc[key] = Object.assign(create(), value);
|
|
1569
|
+
return acc;
|
|
1570
|
+
}, create());
|
|
1571
|
+
const env = Object.assign(create(), CLI_OPTIONS_DEFAULT, cliOptions);
|
|
1572
|
+
if (command.rendering) {
|
|
1573
|
+
const { header, usage, validationErrors } = command.rendering;
|
|
1574
|
+
if (header !== void 0) env.renderHeader = header;
|
|
1575
|
+
if (usage !== void 0) env.renderUsage = usage;
|
|
1576
|
+
if (validationErrors !== void 0) env.renderValidationErrors = validationErrors;
|
|
1577
|
+
}
|
|
1578
|
+
const core = Object.assign(create(), {
|
|
1579
|
+
name: getCommandName(command),
|
|
1580
|
+
description: command.description,
|
|
1581
|
+
omitted,
|
|
1582
|
+
callMode,
|
|
1583
|
+
commandPath,
|
|
1584
|
+
env,
|
|
1585
|
+
args: _args,
|
|
1586
|
+
explicit,
|
|
1587
|
+
values,
|
|
1588
|
+
positionals,
|
|
1589
|
+
rest,
|
|
1590
|
+
_: argv,
|
|
1591
|
+
tokens,
|
|
1592
|
+
toKebab: command.toKebab,
|
|
1593
|
+
log: cliOptions.usageSilent ? NOOP : log,
|
|
1594
|
+
validationError
|
|
1595
|
+
});
|
|
1596
|
+
if (Object.keys(extensions).length > 0) {
|
|
1597
|
+
const ext = create(null);
|
|
1598
|
+
Object.defineProperty(core, "extensions", {
|
|
1599
|
+
value: ext,
|
|
1600
|
+
writable: false,
|
|
1601
|
+
enumerable: true,
|
|
1602
|
+
configurable: true
|
|
1603
|
+
});
|
|
1604
|
+
for (const [key, extension] of Object.entries(extensions)) {
|
|
1605
|
+
ext[key] = await extension.factory(core, command);
|
|
1606
|
+
if (extension.onFactory) await extension.onFactory(core, command);
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
return deepFreeze(core, ["extensions"]);
|
|
1610
|
+
}
|
|
1611
|
+
__name(createCommandContext, "createCommandContext");
|
|
1612
|
+
function getCommandName(cmd) {
|
|
1613
|
+
if (isLazyCommand(cmd)) return cmd.commandName || cmd.name || "(anonymous)";
|
|
1614
|
+
else if (typeof cmd === "object") return cmd.name || "(anonymous)";
|
|
1615
|
+
else return ANONYMOUS_COMMAND_NAME;
|
|
1616
|
+
}
|
|
1617
|
+
__name(getCommandName, "getCommandName");
|
|
1618
|
+
var NOOP_EXTENSION = /* @__PURE__ */ __name(() => {
|
|
1619
|
+
return /* @__PURE__ */ Object.create(null);
|
|
1620
|
+
}, "NOOP_EXTENSION");
|
|
1621
|
+
function plugin(options = {}) {
|
|
1622
|
+
const { id, name, setup, onExtension, dependencies: dependencies2 } = options;
|
|
1623
|
+
const extension = options.extension || NOOP_EXTENSION;
|
|
1624
|
+
const pluginFn = /* @__PURE__ */ __name(async (ctx) => {
|
|
1625
|
+
if (setup) await setup(ctx);
|
|
1626
|
+
}, "pluginFn");
|
|
1627
|
+
const props = {
|
|
1628
|
+
writable: false,
|
|
1629
|
+
enumerable: true,
|
|
1630
|
+
configurable: true
|
|
1631
|
+
};
|
|
1632
|
+
return Object.defineProperties(pluginFn, {
|
|
1633
|
+
id: {
|
|
1634
|
+
value: id,
|
|
1635
|
+
...props
|
|
1636
|
+
},
|
|
1637
|
+
...name && { name: {
|
|
1638
|
+
value: name,
|
|
1639
|
+
...props
|
|
1640
|
+
} },
|
|
1641
|
+
...dependencies2 && { dependencies: {
|
|
1642
|
+
value: dependencies2,
|
|
1643
|
+
...props
|
|
1644
|
+
} },
|
|
1645
|
+
...extension && { extension: {
|
|
1646
|
+
value: {
|
|
1647
|
+
key: Symbol(id),
|
|
1648
|
+
factory: extension,
|
|
1649
|
+
onFactory: onExtension
|
|
1650
|
+
},
|
|
1651
|
+
...props
|
|
1652
|
+
} }
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
__name(plugin, "plugin");
|
|
1656
|
+
|
|
1657
|
+
// ../../node_modules/.bun/@gunshi+plugin-completion@0.32.0+42f10d8c7c361fb1/node_modules/@gunshi/plugin-completion/lib/index.js
|
|
1658
|
+
function kebabnize(str) {
|
|
1659
|
+
return str.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase());
|
|
1660
|
+
}
|
|
1661
|
+
__name(kebabnize, "kebabnize");
|
|
1662
|
+
function isLazyCommand2(cmd) {
|
|
1663
|
+
return typeof cmd === "function" && "commandName" in cmd && !!cmd.commandName;
|
|
1664
|
+
}
|
|
1665
|
+
__name(isLazyCommand2, "isLazyCommand");
|
|
1666
|
+
async function resolveLazyCommand(cmd, name, needRunResolving = false) {
|
|
1667
|
+
let command;
|
|
1668
|
+
if (isLazyCommand2(cmd)) {
|
|
1669
|
+
const baseCommand = {
|
|
1670
|
+
name: cmd.commandName,
|
|
1671
|
+
description: cmd.description,
|
|
1672
|
+
args: cmd.args,
|
|
1673
|
+
examples: cmd.examples,
|
|
1674
|
+
internal: cmd.internal,
|
|
1675
|
+
entry: cmd.entry,
|
|
1676
|
+
subCommands: cmd.subCommands
|
|
1677
|
+
};
|
|
1678
|
+
if ("resource" in cmd && cmd.resource) baseCommand.resource = cmd.resource;
|
|
1679
|
+
command = Object.assign(create2(), baseCommand);
|
|
1680
|
+
if (needRunResolving) {
|
|
1681
|
+
const loaded = await cmd();
|
|
1682
|
+
if (typeof loaded === "function") command.run = loaded;
|
|
1683
|
+
else if (typeof loaded === "object") {
|
|
1684
|
+
if (loaded.run == null) throw new TypeError(`'run' is required in command: ${cmd.name || name}`);
|
|
1685
|
+
command.run = loaded.run;
|
|
1686
|
+
command.name = loaded.name;
|
|
1687
|
+
command.description = loaded.description;
|
|
1688
|
+
command.args = loaded.args;
|
|
1689
|
+
command.examples = loaded.examples;
|
|
1690
|
+
command.internal = loaded.internal;
|
|
1691
|
+
command.entry = loaded.entry;
|
|
1692
|
+
command.subCommands = loaded.subCommands || cmd.subCommands;
|
|
1693
|
+
if ("resource" in loaded && loaded.resource) command.resource = loaded.resource;
|
|
1694
|
+
} else throw new TypeError(`Cannot resolve command: ${cmd.name || name}`);
|
|
1695
|
+
}
|
|
1696
|
+
} else command = Object.assign(create2(), cmd);
|
|
1697
|
+
if (command.name == null && name) command.name = name;
|
|
1698
|
+
return deepFreeze2(command);
|
|
1699
|
+
}
|
|
1700
|
+
__name(resolveLazyCommand, "resolveLazyCommand");
|
|
1701
|
+
function create2(obj = null) {
|
|
1702
|
+
return Object.create(obj);
|
|
1703
|
+
}
|
|
1704
|
+
__name(create2, "create");
|
|
1705
|
+
function deepFreeze2(obj, ignores = []) {
|
|
1706
|
+
if (obj === null || typeof obj !== "object") return obj;
|
|
1707
|
+
for (const key of Object.keys(obj)) {
|
|
1708
|
+
const value = obj[key];
|
|
1709
|
+
if (ignores.includes(key)) continue;
|
|
1710
|
+
if (typeof value === "object" && value !== null) deepFreeze2(value, ignores);
|
|
1711
|
+
}
|
|
1712
|
+
return Object.freeze(obj);
|
|
1713
|
+
}
|
|
1714
|
+
__name(deepFreeze2, "deepFreeze");
|
|
1715
|
+
var BUILD_IN_PREFIX_AND_KEY_SEPARATOR = `_:`;
|
|
1716
|
+
var ARG_PREFIX_AND_KEY_SEPARATOR = `arg:`;
|
|
1717
|
+
var NEGATABLE = "Negatable of";
|
|
1718
|
+
var en_US_default = {
|
|
1719
|
+
COMMAND: "COMMAND",
|
|
1720
|
+
COMMANDS: "COMMANDS",
|
|
1721
|
+
SUBCOMMAND: "SUBCOMMAND",
|
|
1722
|
+
USAGE: "USAGE",
|
|
1723
|
+
ARGUMENTS: "ARGUMENTS",
|
|
1724
|
+
OPTIONS: "OPTIONS",
|
|
1725
|
+
EXAMPLES: "EXAMPLES",
|
|
1726
|
+
FORMORE: "For more info, run any command with the `--help` flag",
|
|
1727
|
+
NEGATABLE,
|
|
1728
|
+
DEFAULT: "default",
|
|
1729
|
+
CHOICES: "choices",
|
|
1730
|
+
help: "Display this help message",
|
|
1731
|
+
version: "Display this version"
|
|
1732
|
+
};
|
|
1733
|
+
function resolveArgKey(key, name) {
|
|
1734
|
+
return `${name ? `${name}:` : ""}arg:${key}`;
|
|
1735
|
+
}
|
|
1736
|
+
__name(resolveArgKey, "resolveArgKey");
|
|
1737
|
+
function resolveKey(key, name) {
|
|
1738
|
+
return `${name ? `${name}:` : ""}${key}`;
|
|
1739
|
+
}
|
|
1740
|
+
__name(resolveKey, "resolveKey");
|
|
1741
|
+
async function resolveExamples(ctx, examples) {
|
|
1742
|
+
return typeof examples === "string" ? examples : typeof examples === "function" ? await examples(ctx) : "";
|
|
1743
|
+
}
|
|
1744
|
+
__name(resolveExamples, "resolveExamples");
|
|
1745
|
+
function namespacedId(id) {
|
|
1746
|
+
return `g:${id}`;
|
|
1747
|
+
}
|
|
1748
|
+
__name(namespacedId, "namespacedId");
|
|
1749
|
+
function makeShortLongOptionPair(schema, name, toKebab) {
|
|
1750
|
+
let key = `--${toKebab || schema.toKebab ? kebabnize(name) : name}`;
|
|
1751
|
+
if (schema.short) key = `-${schema.short}, ${key}`;
|
|
1752
|
+
return key;
|
|
1753
|
+
}
|
|
1754
|
+
__name(makeShortLongOptionPair, "makeShortLongOptionPair");
|
|
1755
|
+
function localizable(ctx, cmd, translate) {
|
|
1756
|
+
async function localize(key, values) {
|
|
1757
|
+
if (translate) return translate(key, values);
|
|
1758
|
+
if (key.startsWith(BUILD_IN_PREFIX_AND_KEY_SEPARATOR)) return en_US_default[key.slice(BUILD_IN_PREFIX_AND_KEY_SEPARATOR.length)] || key;
|
|
1759
|
+
const namaspacedArgKey = resolveKey(ARG_PREFIX_AND_KEY_SEPARATOR, ctx.name);
|
|
1760
|
+
if (key.startsWith(namaspacedArgKey)) {
|
|
1761
|
+
let argKey = key.slice(namaspacedArgKey.length);
|
|
1762
|
+
let negatable = false;
|
|
1763
|
+
if (argKey.startsWith("no-")) {
|
|
1764
|
+
argKey = argKey.slice(3);
|
|
1765
|
+
negatable = true;
|
|
1766
|
+
}
|
|
1767
|
+
const schema = ctx.args[argKey];
|
|
1768
|
+
if (!schema) return argKey;
|
|
1769
|
+
return negatable && schema.type === "boolean" && schema.negatable ? `${NEGATABLE} ${makeShortLongOptionPair(schema, argKey, ctx.toKebab)}` : schema.description || "";
|
|
1770
|
+
}
|
|
1771
|
+
if (key === resolveKey("description", ctx.name)) return "";
|
|
1772
|
+
else if (key === resolveKey("examples", ctx.name)) return await resolveExamples(ctx, cmd.examples);
|
|
1773
|
+
else return key;
|
|
1774
|
+
}
|
|
1775
|
+
__name(localize, "localize");
|
|
1776
|
+
return localize;
|
|
1777
|
+
}
|
|
1778
|
+
__name(localizable, "localizable");
|
|
1779
|
+
var pluginId = namespacedId("completion");
|
|
1780
|
+
function getRuntimeGlobals() {
|
|
1781
|
+
return globalThis;
|
|
1782
|
+
}
|
|
1783
|
+
__name(getRuntimeGlobals, "getRuntimeGlobals");
|
|
1784
|
+
function detectRuntime() {
|
|
1785
|
+
return detectRuntimeFromGlobals(getRuntimeGlobals());
|
|
1786
|
+
}
|
|
1787
|
+
__name(detectRuntime, "detectRuntime");
|
|
1788
|
+
function detectRuntimeFromGlobals(globals) {
|
|
1789
|
+
if (globals.Bun !== void 0) return "bun";
|
|
1790
|
+
if (globals.Deno !== void 0) return "deno";
|
|
1791
|
+
if (globals.process !== void 0 && globals.process.release?.name === "node") return "node";
|
|
1792
|
+
return "unknown";
|
|
1793
|
+
}
|
|
1794
|
+
__name(detectRuntimeFromGlobals, "detectRuntimeFromGlobals");
|
|
1795
|
+
function shellQuote(value) {
|
|
1796
|
+
if (value.length === 0) return "''";
|
|
1797
|
+
if (/^[\w%+,./:=@-]+$/.test(value)) return value;
|
|
1798
|
+
return `'${value.replaceAll(`'`, `'\\''`)}'`;
|
|
1799
|
+
}
|
|
1800
|
+
__name(shellQuote, "shellQuote");
|
|
1801
|
+
function escapeDoubleQuotedShellString(value) {
|
|
1802
|
+
return value.replaceAll(/[$`"\\]/g, "\\$&");
|
|
1803
|
+
}
|
|
1804
|
+
__name(escapeDoubleQuotedShellString, "escapeDoubleQuotedShellString");
|
|
1805
|
+
function basename(path2) {
|
|
1806
|
+
const slash = path2.lastIndexOf("/");
|
|
1807
|
+
const backslash = path2.lastIndexOf("\\");
|
|
1808
|
+
return path2.slice(Math.max(slash, backslash) + 1);
|
|
1809
|
+
}
|
|
1810
|
+
__name(basename, "basename");
|
|
1811
|
+
function isBunVirtualEntry(entry) {
|
|
1812
|
+
return entry?.startsWith("/$bunfs/") === true || entry?.startsWith("B:\\~BUN\\") === true || entry?.startsWith("B:/~BUN/") === true;
|
|
1813
|
+
}
|
|
1814
|
+
__name(isBunVirtualEntry, "isBunVirtualEntry");
|
|
1815
|
+
function isLikelyBunSingleBinary(execPath, entry) {
|
|
1816
|
+
const name = basename(execPath).toLowerCase();
|
|
1817
|
+
if (name !== "bun" && name !== "bun.exe") return true;
|
|
1818
|
+
return isBunVirtualEntry(entry);
|
|
1819
|
+
}
|
|
1820
|
+
__name(isLikelyBunSingleBinary, "isLikelyBunSingleBinary");
|
|
1821
|
+
function resolveNodeExecParts(process3) {
|
|
1822
|
+
const entry = process3.argv[1];
|
|
1823
|
+
return [
|
|
1824
|
+
process3.execPath,
|
|
1825
|
+
...process3.execArgv ?? [],
|
|
1826
|
+
...entry ? [entry] : []
|
|
1827
|
+
];
|
|
1828
|
+
}
|
|
1829
|
+
__name(resolveNodeExecParts, "resolveNodeExecParts");
|
|
1830
|
+
function resolveBunExecParts(process3) {
|
|
1831
|
+
const entry = process3.argv[1];
|
|
1832
|
+
if (isLikelyBunSingleBinary(process3.execPath, entry)) return [process3.execPath];
|
|
1833
|
+
return [
|
|
1834
|
+
process3.execPath,
|
|
1835
|
+
...process3.execArgv ?? [],
|
|
1836
|
+
...entry ? [entry] : []
|
|
1837
|
+
];
|
|
1838
|
+
}
|
|
1839
|
+
__name(resolveBunExecParts, "resolveBunExecParts");
|
|
1840
|
+
function joinExecParts(parts) {
|
|
1841
|
+
return escapeDoubleQuotedShellString(parts.map(shellQuote).join(" "));
|
|
1842
|
+
}
|
|
1843
|
+
__name(joinExecParts, "joinExecParts");
|
|
1844
|
+
function quoteExec() {
|
|
1845
|
+
const globals = getRuntimeGlobals();
|
|
1846
|
+
switch (detectRuntime()) {
|
|
1847
|
+
case "node":
|
|
1848
|
+
return joinExecParts(resolveNodeExecParts(globals.process));
|
|
1849
|
+
case "deno":
|
|
1850
|
+
throw new Error("Deno runtime is not supported for completion script generation yet.");
|
|
1851
|
+
case "bun":
|
|
1852
|
+
return joinExecParts(resolveBunExecParts(globals.process));
|
|
1853
|
+
default:
|
|
1854
|
+
throw new Error("Unsupported JavaScript runtime for completion script generation.");
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
__name(quoteExec, "quoteExec");
|
|
1858
|
+
var TERMINATOR = "--";
|
|
1859
|
+
var NOOP_HANDLER = /* @__PURE__ */ __name(() => {
|
|
1860
|
+
return [];
|
|
1861
|
+
}, "NOOP_HANDLER");
|
|
1862
|
+
var i18nPluginId = namespacedId("i18n");
|
|
1863
|
+
var dependencies = [{
|
|
1864
|
+
id: i18nPluginId,
|
|
1865
|
+
optional: true
|
|
1866
|
+
}];
|
|
1867
|
+
function completion(options = {}) {
|
|
1868
|
+
const config = options.config || {};
|
|
1869
|
+
const t2 = new l();
|
|
1870
|
+
return plugin({
|
|
1871
|
+
id: pluginId,
|
|
1872
|
+
name: "completion",
|
|
1873
|
+
dependencies,
|
|
1874
|
+
setup(ctx) {
|
|
1875
|
+
const completeName = "complete";
|
|
1876
|
+
ctx.addCommand(completeName, {
|
|
1877
|
+
name: completeName,
|
|
1878
|
+
description: "Generate shell completion script",
|
|
1879
|
+
rendering: { header: null },
|
|
1880
|
+
run: /* @__PURE__ */ __name((cmdCtx) => {
|
|
1881
|
+
if (!cmdCtx.env.name) throw new Error("your cli name is not defined.");
|
|
1882
|
+
let shell = cmdCtx._[1];
|
|
1883
|
+
if (shell === TERMINATOR) shell = void 0;
|
|
1884
|
+
if (shell === void 0) t2.parse(cmdCtx._.slice(cmdCtx._.indexOf(TERMINATOR) + 1));
|
|
1885
|
+
else if ([
|
|
1886
|
+
"zsh",
|
|
1887
|
+
"bash",
|
|
1888
|
+
"fish",
|
|
1889
|
+
"powershell"
|
|
1890
|
+
].includes(shell)) t2.setup(cmdCtx.env.name, quoteExec(), shell);
|
|
1891
|
+
}, "run")
|
|
1892
|
+
});
|
|
1893
|
+
},
|
|
1894
|
+
/**
|
|
1895
|
+
* setup bombshell completion with `onExtension` hook
|
|
1896
|
+
*/
|
|
1897
|
+
onExtension: /* @__PURE__ */ __name(async (ctx, cmd) => {
|
|
1898
|
+
const i18n = ctx.extensions[i18nPluginId];
|
|
1899
|
+
const subCommands2 = ctx.env.subCommands;
|
|
1900
|
+
await registerCompletion({
|
|
1901
|
+
name: "entry",
|
|
1902
|
+
cmd: [...subCommands2].map(([_, cmd2]) => cmd2).find((cmd2) => cmd2.entry) || cmd,
|
|
1903
|
+
config,
|
|
1904
|
+
i18nPluginId,
|
|
1905
|
+
i18n,
|
|
1906
|
+
t: t2,
|
|
1907
|
+
isBombshellRoot: true
|
|
1908
|
+
});
|
|
1909
|
+
await handleSubCommands(t2, subCommands2, i18nPluginId, config.subCommands, i18n);
|
|
1910
|
+
}, "onExtension")
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
__name(completion, "completion");
|
|
1914
|
+
async function registerCompletion({ name, cmd, config, i18nPluginId: i18nPluginId2, i18n, t: t2, isBombshellRoot = false }) {
|
|
1915
|
+
const resolvedCmd = await resolveLazyCommand(cmd);
|
|
1916
|
+
const extensions = /* @__PURE__ */ Object.create(null);
|
|
1917
|
+
if (i18n) extensions[i18nPluginId2] = {
|
|
1918
|
+
key: Symbol(i18nPluginId2),
|
|
1919
|
+
factory: /* @__PURE__ */ __name(() => i18n, "factory")
|
|
1920
|
+
};
|
|
1921
|
+
const ctx = await createCommandContext({
|
|
1922
|
+
args: resolvedCmd.args || /* @__PURE__ */ Object.create(null),
|
|
1923
|
+
command: resolvedCmd,
|
|
1924
|
+
callMode: resolvedCmd.entry ? "entry" : "subCommand",
|
|
1925
|
+
extensions
|
|
1926
|
+
});
|
|
1927
|
+
if (i18n) {
|
|
1928
|
+
if (!await i18n.loadResource(i18n.locale, ctx, resolvedCmd)) console.warn(`Failed to load i18n resources for command: ${name} (${i18n.locale.toString()})`);
|
|
1929
|
+
}
|
|
1930
|
+
const localizeDescription = localizable(ctx, resolvedCmd, i18n ? i18n.translate : void 0);
|
|
1931
|
+
const commandTab = isBombshellRoot ? t2 : t2.command(name, await localizeDescription(resolveKey("description", ctx.name)) || resolvedCmd.description || "");
|
|
1932
|
+
const args = resolvedCmd.args || /* @__PURE__ */ Object.create(null);
|
|
1933
|
+
for (const [key, schema] of Object.entries(args)) if (schema.type === "positional") commandTab.argument(key, resolveCompletionHandler(name, key, config, i18n), schema.multiple);
|
|
1934
|
+
else commandTab.option(key, await localizeDescription(resolveArgKey(key, ctx.name)) || schema.description || "", resolveCompletionHandler(name, key, config, i18n), schema.short);
|
|
1935
|
+
}
|
|
1936
|
+
__name(registerCompletion, "registerCompletion");
|
|
1937
|
+
function resolveCompletionHandler(name, optionOrArgKey, config, i18n) {
|
|
1938
|
+
return function(complete) {
|
|
1939
|
+
const handler = config[name]?.args?.[optionOrArgKey]?.handler || NOOP_HANDLER;
|
|
1940
|
+
for (const item of handler({ locale: i18n?.locale })) complete(item.value, item.description || "");
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
__name(resolveCompletionHandler, "resolveCompletionHandler");
|
|
1944
|
+
async function handleSubCommands(t2, subCommands2, i18nPluginId2, config = {}, i18n, parentPath = "") {
|
|
1945
|
+
for (const [name, cmd] of subCommands2) {
|
|
1946
|
+
if (cmd.internal || cmd.entry || name === "complete") continue;
|
|
1947
|
+
const fullName = parentPath ? `${parentPath} ${name}` : name;
|
|
1948
|
+
await registerCompletion({
|
|
1949
|
+
name: fullName,
|
|
1950
|
+
cmd,
|
|
1951
|
+
config,
|
|
1952
|
+
i18nPluginId: i18nPluginId2,
|
|
1953
|
+
i18n,
|
|
1954
|
+
t: t2
|
|
1955
|
+
});
|
|
1956
|
+
const nestedSubCommands = getNestedSubCommands(cmd);
|
|
1957
|
+
if (nestedSubCommands && nestedSubCommands.size > 0) await handleSubCommands(t2, nestedSubCommands, i18nPluginId2, config, i18n, fullName);
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
__name(handleSubCommands, "handleSubCommands");
|
|
1961
|
+
function getNestedSubCommands(cmd) {
|
|
1962
|
+
const subCommands2 = typeof cmd === "function" ? cmd.subCommands : cmd.subCommands;
|
|
1963
|
+
if (!subCommands2) return;
|
|
1964
|
+
if (subCommands2 instanceof Map) return subCommands2.size > 0 ? subCommands2 : void 0;
|
|
1965
|
+
if (typeof subCommands2 === "object") {
|
|
1966
|
+
const entries = Object.entries(subCommands2);
|
|
1967
|
+
if (entries.length === 0) return;
|
|
1968
|
+
const map = /* @__PURE__ */ new Map();
|
|
1969
|
+
for (const [name, c2] of entries) map.set(name, c2);
|
|
1970
|
+
return map;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
__name(getNestedSubCommands, "getNestedSubCommands");
|
|
488
1974
|
var VARLOCK_BANNER = [
|
|
489
1975
|
"",
|
|
490
1976
|
" \u2588\u2588\u2592 \u2588\u2593 \u2584\u2584\u2584 \u2588\u2588\u2580\u2588\u2588\u2588 \u2588\u2588\u2593 \u2592\u2588\u2588\u2588\u2588\u2588 \u2584\u2588\u2588\u2588\u2588\u2584 \u2588\u2588 \u2584\u2588\u2580",
|
|
@@ -602,7 +2088,7 @@ var is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
|
602
2088
|
// package.json
|
|
603
2089
|
var package_default = {
|
|
604
2090
|
name: "varlock",
|
|
605
|
-
version: "1.
|
|
2091
|
+
version: "1.4.0",
|
|
606
2092
|
description: "AI-safe .env files: Schemas for agents, Secrets for humans.",
|
|
607
2093
|
main: "index.js",
|
|
608
2094
|
type: "module",
|
|
@@ -742,8 +2228,9 @@ var package_default = {
|
|
|
742
2228
|
ansis: "catalog:",
|
|
743
2229
|
"browser-or-node": "^3.0.0",
|
|
744
2230
|
"ci-info": "^4.3.1",
|
|
2231
|
+
"@gunshi/plugin-completion": "^0.32.0",
|
|
745
2232
|
"exit-hook": "^5.1.0",
|
|
746
|
-
gunshi: "^0.
|
|
2233
|
+
gunshi: "^0.32.0",
|
|
747
2234
|
"is-docker": "^4.0.0",
|
|
748
2235
|
"is-unicode-supported": "^2.1.0",
|
|
749
2236
|
"is-wsl": "^3.1.0",
|
|
@@ -1002,20 +2489,20 @@ function buildLazyCommand(commandSpec15, loadCommandFn) {
|
|
|
1002
2489
|
}
|
|
1003
2490
|
__name(buildLazyCommand, "buildLazyCommand");
|
|
1004
2491
|
var subCommands = /* @__PURE__ */ new Map();
|
|
1005
|
-
subCommands.set("init", buildLazyCommand(commandSpec, async () => await import('../init.command-
|
|
1006
|
-
subCommands.set("load", buildLazyCommand(commandSpec$1, async () => await import('../load.command-
|
|
1007
|
-
subCommands.set("run", buildLazyCommand(commandSpec$2, async () => await import('../run.command-
|
|
1008
|
-
subCommands.set("printenv", buildLazyCommand(commandSpec$3, async () => await import('../printenv.command-
|
|
1009
|
-
subCommands.set("encrypt", buildLazyCommand(commandSpec$4, async () => await import('../encrypt.command-
|
|
1010
|
-
subCommands.set("lock", buildLazyCommand(commandSpec$5, async () => await import('../lock.command-
|
|
1011
|
-
subCommands.set("reveal", buildLazyCommand(commandSpec$6, async () => await import('../reveal.command-
|
|
1012
|
-
subCommands.set("explain", buildLazyCommand(commandSpec$7, async () => await import('../explain.command-
|
|
1013
|
-
subCommands.set("help", buildLazyCommand(commandSpec$8, async () => await import('../help.command-
|
|
1014
|
-
subCommands.set("telemetry", buildLazyCommand(commandSpec$9, async () => await import('../telemetry.command-
|
|
1015
|
-
subCommands.set("scan", buildLazyCommand(commandSpec$a, async () => await import('../scan.command-
|
|
1016
|
-
subCommands.set("audit", buildLazyCommand(commandSpec$b, async () => await import('../audit.command-
|
|
1017
|
-
subCommands.set("typegen", buildLazyCommand(commandSpec$c, async () => await import('../typegen.command-
|
|
1018
|
-
subCommands.set("install-plugin", buildLazyCommand(commandSpec$d, async () => await import('../install-plugin.command-
|
|
2492
|
+
subCommands.set("init", buildLazyCommand(commandSpec, async () => await import('../init.command-FFORG2JL.js')));
|
|
2493
|
+
subCommands.set("load", buildLazyCommand(commandSpec$1, async () => await import('../load.command-V3C5H6CZ.js')));
|
|
2494
|
+
subCommands.set("run", buildLazyCommand(commandSpec$2, async () => await import('../run.command-TRSRYDOM.js')));
|
|
2495
|
+
subCommands.set("printenv", buildLazyCommand(commandSpec$3, async () => await import('../printenv.command-2BIP7FCF.js')));
|
|
2496
|
+
subCommands.set("encrypt", buildLazyCommand(commandSpec$4, async () => await import('../encrypt.command-7M34IUJY.js')));
|
|
2497
|
+
subCommands.set("lock", buildLazyCommand(commandSpec$5, async () => await import('../lock.command-QQV2S6NY.js')));
|
|
2498
|
+
subCommands.set("reveal", buildLazyCommand(commandSpec$6, async () => await import('../reveal.command-7LHNCYS4.js')));
|
|
2499
|
+
subCommands.set("explain", buildLazyCommand(commandSpec$7, async () => await import('../explain.command-LZJOP4TM.js')));
|
|
2500
|
+
subCommands.set("help", buildLazyCommand(commandSpec$8, async () => await import('../help.command-VIBYZWCF.js')));
|
|
2501
|
+
subCommands.set("telemetry", buildLazyCommand(commandSpec$9, async () => await import('../telemetry.command-SMIT5ZZB.js')));
|
|
2502
|
+
subCommands.set("scan", buildLazyCommand(commandSpec$a, async () => await import('../scan.command-NMBEPFUC.js')));
|
|
2503
|
+
subCommands.set("audit", buildLazyCommand(commandSpec$b, async () => await import('../audit.command-PXY2ZGU2.js')));
|
|
2504
|
+
subCommands.set("typegen", buildLazyCommand(commandSpec$c, async () => await import('../typegen.command-C5KWLYPL.js')));
|
|
2505
|
+
subCommands.set("install-plugin", buildLazyCommand(commandSpec$d, async () => await import('../install-plugin.command-SFNHDKVE.js')));
|
|
1019
2506
|
(/* @__PURE__ */ __name(async function go() {
|
|
1020
2507
|
try {
|
|
1021
2508
|
try {
|
|
@@ -1025,6 +2512,7 @@ subCommands.set("install-plugin", buildLazyCommand(commandSpec$d, async () => aw
|
|
|
1025
2512
|
}
|
|
1026
2513
|
let args = process.argv.slice(2);
|
|
1027
2514
|
if (args[0] === "help") args = ["--help"];
|
|
2515
|
+
const isCompletionInvoke = args[0] === "complete";
|
|
1028
2516
|
if (false) ;
|
|
1029
2517
|
if (args[0] === "--version") {
|
|
1030
2518
|
await trackCommand("version");
|
|
@@ -1040,6 +2528,7 @@ subCommands.set("install-plugin", buildLazyCommand(commandSpec$d, async () => aw
|
|
|
1040
2528
|
description: "Encrypt and protect your env vars",
|
|
1041
2529
|
version: versionId,
|
|
1042
2530
|
subCommands,
|
|
2531
|
+
plugins: [completion()],
|
|
1043
2532
|
renderHeader: /* @__PURE__ */ __name(async (ctx) => {
|
|
1044
2533
|
if (ctx.name) return "";
|
|
1045
2534
|
return VARLOCK_BANNER_COLOR;
|
|
@@ -1072,5 +2561,23 @@ subCommands.set("install-plugin", buildLazyCommand(commandSpec$d, async () => aw
|
|
|
1072
2561
|
}
|
|
1073
2562
|
}, "go"))();
|
|
1074
2563
|
//! this ouput is used by homebrew formula to check installed version is correct
|
|
2564
|
+
/*! Bundled license information:
|
|
2565
|
+
|
|
2566
|
+
@gunshi/plugin/lib/index.js:
|
|
2567
|
+
(**
|
|
2568
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
2569
|
+
* @license MIT
|
|
2570
|
+
*)
|
|
2571
|
+
|
|
2572
|
+
@gunshi/plugin-completion/lib/index.js:
|
|
2573
|
+
(*! license ISC
|
|
2574
|
+
* @author Bombshell team and Bombshell contributors
|
|
2575
|
+
* Bombshell related codes are forked from @bombsh/tab
|
|
2576
|
+
*)
|
|
2577
|
+
(**
|
|
2578
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
2579
|
+
* @license MIT
|
|
2580
|
+
*)
|
|
2581
|
+
*/
|
|
1075
2582
|
//# sourceMappingURL=cli-executable.js.map
|
|
1076
2583
|
//# sourceMappingURL=cli-executable.js.map
|