summaryrefslogtreecommitdiff
path: root/scripts/deploy/legacy_completions/powershell/completion_jvv.ps1
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-14 22:12:30 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-14 22:40:12 +0800
commit72f80ea51f25256d0c463c2f3dc3d8670cfc4634 (patch)
treeb200a3ab1a4c718034458863570a064b52bafdcd /scripts/deploy/legacy_completions/powershell/completion_jvv.ps1
parent54b5567d6f1b1adaa6ada6a26faba0c5c492b7f3 (diff)
Add shell completions for new jvn CLI
Diffstat (limited to 'scripts/deploy/legacy_completions/powershell/completion_jvv.ps1')
-rw-r--r--scripts/deploy/legacy_completions/powershell/completion_jvv.ps167
1 files changed, 67 insertions, 0 deletions
diff --git a/scripts/deploy/legacy_completions/powershell/completion_jvv.ps1 b/scripts/deploy/legacy_completions/powershell/completion_jvv.ps1
new file mode 100644
index 0000000..fa773c0
--- /dev/null
+++ b/scripts/deploy/legacy_completions/powershell/completion_jvv.ps1
@@ -0,0 +1,67 @@
+# The JustEnoughVCS CommandLine Completion
+
+Register-ArgumentCompleter -Native -CommandName jvv -ScriptBlock {
+ param($wordToComplete, $commandAst, $cursorPosition)
+
+ $words = $commandAst.CommandElements | ForEach-Object { $_.ToString() }
+ $currentIndex = $words.IndexOf($wordToComplete)
+ if ($currentIndex -lt 0) { $currentIndex = $words.Count }
+
+ $cmd = "jvv"
+ $subcmd = if ($words.Count -gt 1) { $words[1] } else { $null }
+ $subsubcmd = if ($words.Count -gt 2) { $words[2] } else { $null }
+
+ # Base commands
+ $baseCommands = @("create", "init", "here", "member", "service", "listen", "members", "-c", "-i", "-H", "-m", "-l", "-M")
+
+ # Member subcommands
+ $memberCommands = @("register", "remove", "list", "help", "+", "-", "ls")
+
+ # Service subcommands
+ $serviceCommands = @("listen", "help")
+
+ # Completion for main command
+ if ($currentIndex -eq 1) {
+ return $baseCommands | Where-Object { $_ -like "$wordToComplete*" }
+ }
+
+ # Completion for member command
+ if ($subcmd -eq "member" -or $subcmd -eq "-m") {
+ if ($currentIndex -eq 2) {
+ return $memberCommands | Where-Object { $_ -like "$wordToComplete*" }
+ }
+
+ switch ($subsubcmd) {
+ { @("remove", "-") -contains $_ } {
+ if ($currentIndex -eq 3) {
+ $members = & $cmd member list --raw 2>$null
+ return $members | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ }
+ return @()
+ }
+
+ # Completion for service command
+ if ($subcmd -eq "service") {
+ if ($currentIndex -eq 2) {
+ return $serviceCommands | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ return @()
+ }
+
+ # Aliases completion
+ switch ($subcmd) {
+ "-m" {
+ if ($currentIndex -eq 2) {
+ return $memberCommands | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ { @("listen", "-l", "members", "-M") -contains $_ } {
+ # These commands have no arguments to complete
+ return @()
+ }
+ }
+
+ return @()
+}