summaryrefslogtreecommitdiff
path: root/scripts/deploy
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-07 15:46:40 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-07 15:46:40 +0800
commite580d5db3cc4146a4e3006492f7ced26b8e8072c (patch)
treeaa56e423b25982f9f7422114f81b362ef5f034d9 /scripts/deploy
parent197363c9ed2b285db220988590dfc13edcbbad41 (diff)
Move deployment scripts to deploy subdirectory
Diffstat (limited to 'scripts/deploy')
-rw-r--r--scripts/deploy/completions/bash/completion_jv.sh272
-rw-r--r--scripts/deploy/completions/bash/completion_jvv.sh78
-rw-r--r--scripts/deploy/completions/powershell/completion_jv.ps1250
-rw-r--r--scripts/deploy/completions/powershell/completion_jvv.ps167
-rw-r--r--scripts/deploy/jv_cli.ps163
-rw-r--r--scripts/deploy/jv_cli.sh74
-rw-r--r--scripts/deploy/zsh_support/how_to_install.md61
-rw-r--r--scripts/deploy/zsh_support/install.sh3
-rw-r--r--scripts/deploy/zsh_support/jvcs.plugin.zsh149
9 files changed, 1017 insertions, 0 deletions
diff --git a/scripts/deploy/completions/bash/completion_jv.sh b/scripts/deploy/completions/bash/completion_jv.sh
new file mode 100644
index 0000000..364df9d
--- /dev/null
+++ b/scripts/deploy/completions/bash/completion_jv.sh
@@ -0,0 +1,272 @@
+#!/bin/bash
+# The JustEnoughVCS CommandLine Completion
+
+_jv_completion() {
+ local cur prev words cword
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ words=("${COMP_WORDS[@]}")
+ cword=$COMP_CWORD
+
+ # Current
+ local cmd="${words[0]}"
+ local subcmd="${words[1]}"
+ local subsubcmd="${words[2]}"
+
+ # Subcommands
+ local base_commands="create init direct unstain account update \
+ sheet status here move mv docs exit use sheets accounts \
+ as make drop track hold throw login \
+ jump align info share"
+
+ # Subcommands - Account
+ local account_commands="list as add remove movekey mvkey mvk genpub help"
+
+ # Subcommands - Sheet
+ local sheet_commands="list use exit make drop help align"
+
+ # Subcommands - Sheet
+ local sheet_commands="list use exit make drop help align"
+
+ # Completion subcommands
+ if [[ $cword -eq 1 ]]; then
+ COMPREPLY=($(compgen -W "$base_commands" -- "$cur"))
+ return 0
+ fi
+
+ # Completion account
+ if [[ "$subcmd" == "account" || "$subcmd" == "acc" ]]; then
+ if [[ $cword -eq 2 ]]; then
+ COMPREPLY=($(compgen -W "$account_commands" -- "$cur"))
+ return 0
+ fi
+
+ case "$subsubcmd" in
+ "as"|"remove"|"mvkey"|"mvk"|"movekey"|"genpub")
+ if [[ $cword -eq 3 ]]; then
+ # Use jv account list --raw
+ local accounts
+ accounts=$($cmd account list --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$accounts" -- "$cur"))
+ elif [[ $cword -eq 4 && ("$subsubcmd" == "mvkey" || "$subsubcmd" == "mvk" || "$subsubcmd" == "movekey" || "$subsubcmd" == "genpub") ]]; then
+ COMPREPLY=($(compgen -f -- "$cur"))
+ fi
+ ;;
+ "add")
+ if [[ $cword -eq 3 ]]; then
+ # No completion for account name, let user type it
+ COMPREPLY=()
+ elif [[ $cword -eq 4 && "$cur" == -* ]]; then
+ # Complete --keygen option
+ COMPREPLY=($(compgen -W "--keygen" -- "$cur"))
+ fi
+ ;;
+ "-"|"rm")
+ if [[ $cword -eq 3 ]]; then
+ local accounts
+ accounts=$($cmd account list --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$accounts" -- "$cur"))
+ fi
+ ;;
+ esac
+ return 0
+ fi
+
+ # Completion sheet
+ if [[ "$subcmd" == "sheet" || "$subcmd" == "sh" ]]; then
+ if [[ $cword -eq 2 ]]; then
+ COMPREPLY=($(compgen -W "$sheet_commands" -- "$cur"))
+ return 0
+ fi
+
+ case "$subsubcmd" in
+ # Use jv sheet list --raw --all/--other
+ "use"|"drop")
+ if [[ $cword -eq 3 ]]; then
+ local sheets
+ sheets=$($cmd sheet list --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$sheets" -- "$cur"))
+ fi
+ ;;
+ "make")
+ if [[ $cword -eq 3 ]]; then
+ local all_sheets
+ all_sheets=$($cmd sheet list --all --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$all_sheets" -- "$cur"))
+ fi
+ ;;
+ "align")
+ if [[ $cword -eq 3 ]]; then
+ local align_items="lost moved erased"
+ local unsolved_items
+ unsolved_items=$($cmd sheet align --unsolved --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$align_items $unsolved_items" -- "$cur"))
+ elif [[ $cword -eq 4 ]]; then
+ local item="${words[3]}"
+ local align_operations=""
+ local created_items
+ created_items=$($cmd sheet align --created --raw 2>/dev/null)
+
+ if [[ "$item" == "lost" ]]; then
+ align_operations="confirm"
+ elif [[ "$item" == lost:* ]]; then
+ align_operations="confirm $created_items"
+ elif [[ "$item" == "moved" || "$item" == moved:* ]]; then
+ align_operations="local remote break"
+ elif [[ "$item" == "erased" || "$item" == erased:* ]]; then
+ align_operations="confirm"
+ else
+ align_operations="local remote confirm break $created_items"
+ fi
+
+ COMPREPLY=($(compgen -W "$align_operations" -- "$cur"))
+ fi
+ ;;
+ esac
+ return 0
+ fi
+
+ # Completion align
+ if [[ "$subcmd" == "align" ]]; then
+ if [[ $cword -eq 2 ]]; then
+ local align_items="lost moved erased"
+ local unsolved_items
+ unsolved_items=$($cmd sheet align --unsolved --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$align_items $unsolved_items" -- "$cur"))
+ elif [[ $cword -eq 3 ]]; then
+ local item="${words[2]}"
+ local align_operations=""
+ local created_items
+ created_items=$($cmd sheet align --created --raw 2>/dev/null)
+
+ if [[ "$item" == "lost" ]]; then
+ align_operations="confirm"
+ elif [[ "$item" == lost:* ]]; then
+ align_operations="confirm $created_items"
+ elif [[ "$item" == "moved" || "$item" == moved:* ]]; then
+ align_operations="local remote break"
+ elif [[ "$item" == "erased" || "$item" == erased:* ]]; then
+ align_operations="confirm"
+ else
+ align_operations="local remote confirm break $created_items"
+ fi
+
+ COMPREPLY=($(compgen -W "$align_operations" -- "$cur"))
+ fi
+ return 0
+ fi
+
+ # Completion share
+ if [[ "$subcmd" == "share" ]]; then
+ if [[ $cword -eq 2 ]]; then
+ # First parameter: list, see, jv share list --raw results, or files
+ local share_list
+ share_list=$($cmd share list --raw 2>/dev/null)
+ local first_param_options="list see $share_list"
+ COMPREPLY=($(compgen -W "$first_param_options" -f -- "$cur"))
+ elif [[ $cword -eq 3 ]]; then
+ # Second parameter: depends on first parameter
+ local first_param="${words[2]}"
+
+ if [[ "$first_param" == "list" ]]; then
+ # list -> nothing
+ COMPREPLY=()
+ elif [[ "$first_param" == "see" ]]; then
+ # see -> jv share list --raw results
+ local share_list
+ share_list=$($cmd share list --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$share_list" -- "$cur"))
+ elif [[ "$first_param" == *"@"* ]]; then
+ # Contains "@" (shareid) -> show options
+ COMPREPLY=($(compgen -W "--safe --overwrite --skip --reject" -- "$cur"))
+ else
+ # File input -> show jv sheet list --all --raw results
+ local all_sheets
+ all_sheets=$($cmd sheet list --all --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$all_sheets" -- "$cur"))
+ fi
+ fi
+ # Third parameter: no completion
+ return 0
+ fi
+
+ # Completion login
+ if [[ "$subcmd" == "login" ]]; then
+ if [[ $cword -eq 2 ]]; then
+ local accounts
+ accounts=$($cmd account list --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$accounts" -- "$cur"))
+ elif [[ $cword -eq 3 ]]; then
+ local ip_history
+ ip_history=$($cmd _ip_history 2>/dev/null)
+ COMPREPLY=($(compgen -W "$ip_history" -- "$cur"))
+ fi
+ return 0
+ fi
+
+ # Completion direct
+ if [[ "$subcmd" == "direct" ]]; then
+ if [[ $cword -eq 2 ]]; then
+ local ip_history
+ ip_history=$($cmd _ip_history 2>/dev/null)
+ COMPREPLY=($(compgen -W "$ip_history" -- "$cur"))
+ fi
+ return 0
+ fi
+
+ # Completion info
+ if [[ "$subcmd" == "info" ]]; then
+ if [[ $cword -eq 2 ]]; then
+ COMPREPLY=($(compgen -f -- "$cur"))
+ fi
+ return 0
+ fi
+
+ # aliases
+ case "$subcmd" in
+ "as")
+ if [[ $cword -eq 2 ]]; then
+ local accounts
+ accounts=$($cmd account list --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$accounts" -- "$cur"))
+ fi
+ ;;
+ "use")
+ if [[ $cword -eq 2 ]]; then
+ local sheets
+ sheets=$($cmd sheet list --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$sheets" -- "$cur"))
+ fi
+ ;;
+ "make")
+ if [[ $cword -eq 2 ]]; then
+ local all_sheets
+ all_sheets=$($cmd sheet list --all --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$all_sheets" -- "$cur"))
+ fi
+ ;;
+ "drop")
+ if [[ $cword -eq 2 ]]; then
+ local sheets
+ sheets=$($cmd sheet list --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$sheets" -- "$cur"))
+ fi
+ ;;
+ "docs")
+ if [[ $cword -eq 2 ]]; then
+ local docs
+ docs=$($cmd docs list --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$docs" -- "$cur"))
+ fi
+ ;;
+ "move"|"mv")
+ COMPREPLY=($(compgen -f -- "$cur"))
+ ;;
+ "track"|"hold"|"throw")
+ COMPREPLY=($(compgen -f -- "$cur"))
+ ;;
+ esac
+}
+
+complete -F _jv_completion jv
diff --git a/scripts/deploy/completions/bash/completion_jvv.sh b/scripts/deploy/completions/bash/completion_jvv.sh
new file mode 100644
index 0000000..ce5668b
--- /dev/null
+++ b/scripts/deploy/completions/bash/completion_jvv.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+# The JustEnoughVCS CommandLine Completion
+
+_jvv_completion() {
+ local cur prev words cword
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ words=("${COMP_WORDS[@]}")
+ cword=$COMP_CWORD
+
+ # Current
+ local cmd="${words[0]}"
+ local subcmd="${words[1]}"
+ local subsubcmd="${words[2]}"
+
+ # Subcommands
+ local base_commands="create init here member service listen members -c -i -H -m -l -M"
+
+ # Subcommands - Member
+ local member_commands="register remove list help + - ls"
+
+ # Subcommands - Service
+ local service_commands="listen help"
+
+ # Completion subcommands
+ if [[ $cword -eq 1 ]]; then
+ COMPREPLY=($(compgen -W "$base_commands" -- "$cur"))
+ return 0
+ fi
+
+ # Completion member
+ if [[ "$subcmd" == "member" || "$subcmd" == "-m" ]]; then
+ if [[ $cword -eq 2 ]]; then
+ COMPREPLY=($(compgen -W "$member_commands" -- "$cur"))
+ return 0
+ fi
+
+ case "$subsubcmd" in
+ "remove"|"-")
+ if [[ $cword -eq 3 ]]; then
+ # Use jvv member list --raw
+ local members
+ members=$($cmd member list --raw 2>/dev/null)
+ COMPREPLY=($(compgen -W "$members" -- "$cur"))
+ fi
+ ;;
+ esac
+ return 0
+ fi
+
+ # Completion service
+ if [[ "$subcmd" == "service" ]]; then
+ if [[ $cword -eq 2 ]]; then
+ COMPREPLY=($(compgen -W "$service_commands" -- "$cur"))
+ return 0
+ fi
+ return 0
+ fi
+
+ # aliases
+ case "$subcmd" in
+ "-m")
+ if [[ $cword -eq 2 ]]; then
+ COMPREPLY=($(compgen -W "$member_commands" -- "$cur"))
+ fi
+ ;;
+ "listen"|"-l")
+ # listen command has no arguments to complete
+ ;;
+ "members"|"-M")
+ # members command has no arguments to complete
+ ;;
+ esac
+}
+
+# Register completion function
+complete -F _jvv_completion jvv
diff --git a/scripts/deploy/completions/powershell/completion_jv.ps1 b/scripts/deploy/completions/powershell/completion_jv.ps1
new file mode 100644
index 0000000..84ba01a
--- /dev/null
+++ b/scripts/deploy/completions/powershell/completion_jv.ps1
@@ -0,0 +1,250 @@
+# The JustEnoughVCS CommandLine Completion
+
+Register-ArgumentCompleter -Native -CommandName jv -ScriptBlock {
+ param($wordToComplete, $commandAst, $cursorPosition)
+
+ $words = $commandAst.CommandElements | ForEach-Object { $_.ToString() }
+ $currentIndex = $words.IndexOf($wordToComplete)
+ if ($currentIndex -lt 0) { $currentIndex = $words.Count }
+
+ $cmd = "jv"
+ $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", "direct", "unstain", "account", "update",
+ "sheet", "status", "here", "move", "mv", "docs", "exit", "use", "sheets", "accounts",
+ "as", "make", "drop", "track", "hold", "throw", "login",
+ "jump", "align", "info", "share"
+ )
+
+ # Account subcommands
+ $accountCommands = @("list", "as", "add", "remove", "movekey", "mvkey", "mvk", "genpub", "help")
+
+ # Sheet subcommands
+ $sheetCommands = @("list", "use", "exit", "make", "drop", "help", "align")
+
+ # Completion for main command
+ if ($currentIndex -eq 1) {
+ return $baseCommands | Where-Object { $_ -like "$wordToComplete*" }
+ }
+
+ # Completion for account command
+ if ($subcmd -eq "account" -or $subcmd -eq "acc") {
+ if ($currentIndex -eq 2) {
+ return $accountCommands | Where-Object { $_ -like "$wordToComplete*" }
+ }
+
+ switch ($subsubcmd) {
+ { @("as", "remove", "mvkey", "mvk", "movekey", "genpub") -contains $_ } {
+ if ($currentIndex -eq 3) {
+ $accounts = & $cmd account list --raw 2>$null
+ return $accounts | Where-Object { $_ -like "$wordToComplete*" }
+ } elseif ($currentIndex -eq 4 -and (@("mvkey", "mvk", "movekey", "genpub") -contains $subsubcmd)) {
+ # File completion for key files
+ return Get-ChildItem -Name -File -Path "." | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ "add" {
+ if ($currentIndex -eq 3) {
+ # No completion for account name
+ return @()
+ } elseif ($currentIndex -eq 4 -and $wordToComplete.StartsWith("-")) {
+ # Complete --keygen option
+ if ("--keygen" -like "$wordToComplete*") {
+ return "--keygen"
+ }
+ }
+ }
+ { @("-", "rm") -contains $_ } {
+ if ($currentIndex -eq 3) {
+ $accounts = & $cmd account list --raw 2>$null
+ return $accounts | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ }
+ return @()
+ }
+
+ # Completion for sheet command
+ if ($subcmd -eq "sheet" -or $subcmd -eq "sh") {
+ if ($currentIndex -eq 2) {
+ return $sheetCommands | Where-Object { $_ -like "$wordToComplete*" }
+ }
+
+ switch ($subsubcmd) {
+ { @("use", "drop") -contains $_ } {
+ if ($currentIndex -eq 3) {
+ $sheets = & $cmd sheet list --raw 2>$null
+ return $sheets | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ "make" {
+ if ($currentIndex -eq 3) {
+ $allSheets = & $cmd sheet list --all --raw 2>$null
+ return $allSheets | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ "align" {
+ if ($currentIndex -eq 3) {
+ $alignItems = @("lost", "moved", "erased")
+ $unsolvedItems = & $cmd sheet align --unsolved --raw 2>$null
+ $completions = $alignItems + $unsolvedItems
+ return $completions | Where-Object { $_ -like "$wordToComplete*" }
+ } elseif ($currentIndex -eq 4) {
+ $item = $words[3]
+ $alignOperations = @()
+ $createdItems = & $cmd sheet align --created --raw 2>$null
+
+ if ($item -eq "lost") {
+ $alignOperations = @("confirm")
+ } elseif ($item -like "lost:*") {
+ $alignOperations = @("confirm") + $createdItems
+ } elseif ($item -eq "moved" -or $item -like "moved:*") {
+ $alignOperations = @("local", "remote", "break")
+ } elseif ($item -eq "erased" -or $item -like "erased:*") {
+ $alignOperations = @("confirm")
+ } else {
+ $alignOperations = @("local", "remote", "confirm", "break") + $createdItems
+ }
+
+ return $alignOperations | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ }
+ return @()
+ }
+
+ # Completion for align command
+ if ($subcmd -eq "align") {
+ if ($currentIndex -eq 2) {
+ $alignItems = @("lost", "moved", "erased")
+ $unsolvedItems = & $cmd sheet align --unsolved --raw 2>$null
+ $completions = $alignItems + $unsolvedItems
+ return $completions | Where-Object { $_ -like "$wordToComplete*" }
+ } elseif ($currentIndex -eq 3) {
+ $item = $words[2]
+ $alignOperations = @()
+ $createdItems = & $cmd sheet align --created --raw 2>$null
+
+ if ($item -eq "lost") {
+ $alignOperations = @("confirm")
+ } elseif ($item -like "lost:*") {
+ $alignOperations = @("confirm") + $createdItems
+ } elseif ($item -eq "moved" -or $item -like "moved:*") {
+ $alignOperations = @("local", "remote", "break")
+ } elseif ($item -eq "erased" -or $item -like "erased:*") {
+ $alignOperations = @("confirm")
+ } else {
+ $alignOperations = @("local", "remote", "confirm", "break") + $createdItems
+ }
+
+ return $alignOperations | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ return @()
+ }
+
+ # Completion for login command
+ if ($subcmd -eq "login") {
+ if ($currentIndex -eq 2) {
+ $accounts = & $cmd account list --raw 2>$null
+ return $accounts | Where-Object { $_ -like "$wordToComplete*" }
+ } elseif ($currentIndex -eq 3) {
+ $ipHistory = & $cmd _ip_history 2>$null
+ return $ipHistory | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ return @()
+ }
+
+ # Completion for direct command
+ if ($subcmd -eq "direct") {
+ if ($currentIndex -eq 2) {
+ $ipHistory = & $cmd _ip_history 2>$null
+ return $ipHistory | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ return @()
+ }
+
+ # Completion for info command
+ if ($subcmd -eq "info") {
+ if ($currentIndex -eq 2) {
+ # File completion for the file argument
+ return Get-ChildItem -Name -File -Path "." | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ return @()
+ }
+
+ # Completion for share command
+ if ($subcmd -eq "share") {
+ if ($currentIndex -eq 2) {
+ # First parameter: list, see, jv share list --raw results, or files in current directory
+ $staticOptions = @("list", "see")
+ $shareList = & $cmd share list --raw 2>$null
+ $files = Get-ChildItem -Name -File -Path "." 2>$null
+ $completions = $staticOptions + $shareList + $files
+ return $completions | Where-Object { $_ -like "$wordToComplete*" }
+ } elseif ($currentIndex -eq 3) {
+ # Second parameter: depends on the first parameter
+ $firstParam = $words[2]
+ if ($firstParam -eq "list") {
+ # list -> nothing
+ return @()
+ } elseif ($firstParam -eq "see") {
+ # see -> jv share list --raw results
+ $shareList = & $cmd share list --raw 2>$null
+ return $shareList | Where-Object { $_ -like "$wordToComplete*" }
+ } elseif ($firstParam -like "*@*") {
+ # Contains "@" (shareid) -> show options
+ $options = @("--safe", "--overwrite", "--skip", "--reject")
+ return $options | Where-Object { $_ -like "$wordToComplete*" }
+ } else {
+ # Otherwise, assume it's a file -> show jv sheet list --all --raw results
+ $allSheets = & $cmd sheet list --all --raw 2>$null
+ return $allSheets | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ # Third parameter: no completion
+ return @()
+ }
+
+ # Aliases completion
+ switch ($subcmd) {
+ "as" {
+ if ($currentIndex -eq 2) {
+ $accounts = & $cmd account list --raw 2>$null
+ return $accounts | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ "use" {
+ if ($currentIndex -eq 2) {
+ $sheets = & $cmd sheet list --raw 2>$null
+ return $sheets | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ "make" {
+ if ($currentIndex -eq 2) {
+ $allSheets = & $cmd sheet list --all --raw 2>$null
+ return $allSheets | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ "drop" {
+ if ($currentIndex -eq 2) {
+ $sheets = & $cmd sheet list --raw 2>$null
+ return $sheets | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ "docs" {
+ if ($currentIndex -eq 2) {
+ $docs = & $cmd docs list --raw 2>$null
+ return $docs | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+ { @("move", "mv", "track", "hold", "throw") -contains $_ } {
+ # File completion for file operations
+ return Get-ChildItem -Name -File -Path "." | Where-Object { $_ -like "$wordToComplete*" }
+ }
+ }
+
+ return @()
+}
diff --git a/scripts/deploy/completions/powershell/completion_jvv.ps1 b/scripts/deploy/completions/powershell/completion_jvv.ps1
new file mode 100644
index 0000000..fa773c0
--- /dev/null
+++ b/scripts/deploy/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 @()
+}
diff --git a/scripts/deploy/jv_cli.ps1 b/scripts/deploy/jv_cli.ps1
new file mode 100644
index 0000000..22836c7
--- /dev/null
+++ b/scripts/deploy/jv_cli.ps1
@@ -0,0 +1,63 @@
+$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Definition
+
+##############
+### CONFIG ###
+##############
+
+# Use JV_LANG to set CLI language
+# Supported: en, zh-CN
+# $env:JV_LANG = "en"
+
+# Use JV_AUTO_UPDATE to set auto content update (yes/no)
+# After local operations that change Upstream Vault content
+# Next `jv` command will auto-run `jv update`
+$env:JV_AUTO_UPDATE = "yes"
+
+# Use JV_OUTDATED_MINUTES to set the expiration time (in minutes), requires JV_AUTO_UPDATE to be enabled
+# Next time the `jv` command is used, if the content is outdated, `jv update` will be automatically executed
+# When the set number is < 0, timeout-based update is disabled
+# When the set number = 0, update runs every time (not recommended)
+# When the set number > 0, update according to the specified time
+# If not set, the default is -1
+# $env:JV_OUTDATED_MINUTES = "5"
+
+# Use JV_TEXT_EDITOR to set text editor for `jv track --work` `jv align --work`
+# DEFAULT: $EDITOR environment variable, falling back to "jvii" if not set
+# $env:JV_TEXT_EDITOR = "nano"
+
+###############
+### ALIASES ###
+###############
+
+function jv {
+ & (Get-Command jv -CommandType Application) @args
+}
+
+function jvh { jv here @args }
+function jvu { jv update @args }
+function jvt { jv track @args }
+function jmv { jv move @args }
+
+Set-Alias jvh jvh
+Set-Alias jvu jvu
+Set-Alias jvt jvt
+Set-Alias jmv jmv
+
+##################
+### COMPLETION ###
+##################
+
+if (Test-Path "$SCRIPT_DIR\completions\powershell\completion_jv.ps1") {
+ . "$SCRIPT_DIR\completions\powershell\completion_jv.ps1"
+}
+if (Test-Path "$SCRIPT_DIR\completions\powershell\completion_jvv.ps1") {
+ . "$SCRIPT_DIR\completions\powershell\completion_jvv.ps1"
+}
+
+###################
+### ENVIRONMENT ###
+###################
+
+if (Test-Path "$SCRIPT_DIR\bin") {
+ $env:PATH = "$SCRIPT_DIR\bin;" + $env:PATH
+}
diff --git a/scripts/deploy/jv_cli.sh b/scripts/deploy/jv_cli.sh
new file mode 100644
index 0000000..d732d95
--- /dev/null
+++ b/scripts/deploy/jv_cli.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+
+##############
+### CONFIG ###
+##############
+
+# Use JV_LANG to set CLI language
+# Supported: en, zh-CN
+# export JV_LANG=en
+
+# Use JV_AUTO_UPDATE to set auto content update (yes/no)
+# After local operations that change Upstream Vault content
+# Next `jv` command will auto-run `jv update`
+export JV_AUTO_UPDATE=yes
+
+# Use JV_OUTDATED_MINUTES to set the expiration time (in minutes), requires JV_AUTO_UPDATE to be enabled
+# Next time the `jv` command is used, if the content is outdated, `jv update` will be automatically executed
+# When the set number is < 0, timeout-based update is disabled
+# When the set number = 0, update runs every time (not recommended)
+# When the set number > 0, update according to the specified time
+# If not set, the default is -1
+# export JV_OUTDATED_MINUTES=5
+
+# Use JV_TEXT_EDITOR to set text editor for `jv track --work` `jv align --work`
+# DEFAULT: $EDITOR environment variable, falling back to "jvii" if not set
+# export JV_TEXT_EDITOR=nano
+
+###############
+### ALIASES ###
+###############
+
+# Disable glob expansion for jv commands across shells
+if [ -n "$BASH_VERSION" ]; then # Bash
+ alias jv='set -f; command jv; set +f'
+ alias jvt='set -f; command jv track; set +f'
+ alias jmv='set -f; command jv move; set +f'
+elif [ -n "$ZSH_VERSION" ]; then # Zsh
+ alias jv='noglob jv'
+ alias jvt='noglob jv track'
+ alias jmv='noglob jv move'
+elif [ -n "$FISH_VERSION" ]; then # Fish
+ function jv {
+ command jv $@
+ }
+ function jvt {
+ command jv track $@
+ }
+ function jmv {
+ command jv move $@
+ }
+fi
+
+alias jvh='jv here'
+alias jvu='jv update'
+
+##################
+### COMPLETION ###
+##################
+
+if [ -f "$SCRIPT_DIR/completions/bash/completion_jv.sh" ]; then
+ source "$SCRIPT_DIR/completions/bash/completion_jv.sh"
+fi
+if [ -f "$SCRIPT_DIR/completions/bash/completion_jvv.sh" ]; then
+ source "$SCRIPT_DIR/completions/bash/completion_jvv.sh"
+fi
+
+##################
+### ENVIREMENT ###
+##################
+
+if [ -d "$SCRIPT_DIR/bin" ]; then
+ export PATH="$SCRIPT_DIR/bin:$PATH"
+fi
diff --git a/scripts/deploy/zsh_support/how_to_install.md b/scripts/deploy/zsh_support/how_to_install.md
new file mode 100644
index 0000000..343ea7b
--- /dev/null
+++ b/scripts/deploy/zsh_support/how_to_install.md
@@ -0,0 +1,61 @@
+# How to Install
+
+Before installing, please ensure:
+
+* [Oh My Zsh](https://ohmyz.sh/) is installed.
+* Your current shell is **Zsh**.
+
+---
+
+## Install the Zsh Plugin
+
+In your terminal, run:
+
+```bash
+./install.sh
+```
+
+This script will install JVCS's Zsh support files locally and prepare the prompt segment definitions for use by your theme.
+
+---
+
+## Configure Your Zsh Theme
+
+Open your current Zsh theme file (e.g., `~/.oh-my-zsh/themes/xxx.zsh-theme`) and paste the following content in an appropriate location:
+
+```bash
+# ----------------------------------------------------- #
+# DISPLAY_LEVEL
+# FULL = 127.0.0.1:25331/account/sheet
+# NORMAL = account/sheet
+# SHORT = sheet
+JVCS_VIEW='NORMAL'
+
+# Customizable prompt segment elements
+JVCS_PREFIX='['
+JVCS_SPLIT='/'
+JVCS_SUFFIX=']'
+
+# JVCS_PROMPT_SEGMENT default style:
+# [your_account/your_sheet]
+
+# Append JVCS prompt segment
+PROMPT+='${JVCS_PROMPT_SEGMENT}'
+# ----------------------------------------------------- #
+```
+
+After saving, reload your terminal, or run:
+
+```bash
+source ~/.zshrc
+```
+
+---
+
+## Notes
+
+* `JVCS_VIEW` controls the view level displayed in the prompt.
+* `JVCS_PREFIX / SPLIT / SUFFIX` are used to customize the appearance.
+* `JVCS_PROMPT_SEGMENT` is only responsible for displaying the status and does not execute any logic.
+
+No further configuration is required.
diff --git a/scripts/deploy/zsh_support/install.sh b/scripts/deploy/zsh_support/install.sh
new file mode 100644
index 0000000..aa92952
--- /dev/null
+++ b/scripts/deploy/zsh_support/install.sh
@@ -0,0 +1,3 @@
+#!/bin/zsh
+cd "$(dirname "$0")"
+cp jvcs.plugin.zsh ~/.oh-my-zsh/custom/plugins/jvcs/jvcs.plugin.zsh
diff --git a/scripts/deploy/zsh_support/jvcs.plugin.zsh b/scripts/deploy/zsh_support/jvcs.plugin.zsh
new file mode 100644
index 0000000..2032044
--- /dev/null
+++ b/scripts/deploy/zsh_support/jvcs.plugin.zsh
@@ -0,0 +1,149 @@
+# ████████ ████████
+# ██▒▒▒▒▒▒▒▒██ ██▒▒▒▒▒▒▒▒██
+# ██ ▒▒██ ██▒▒ ██ █████ ██ ██ ██████ █████
+# ██ ▒▒████████▒▒ ██ ▒▒▒██ ██ ██ ██████ ██████
+# ██ ▒▒▒▒▒▒▒▒ ██ ██ ██ ██ ███▒▒▒█ █▒▒▒▒█
+# ██ ██ ██ ██ ██ ███ ▒ ████ ▒
+# ██ ██ ██ ██ ██ ███ ▒████
+# ██ ████ ████ ██ ██ ▒██ ██▒ ███ ▒▒▒██
+# ██ ████ ████ ██ █ ██ ██ ██ ███ █ ██ ██
+# ██ ████ ████ ██ █ ██ ▒████▒ ▒██████ ██████
+# ██ ▒▒▒▒ ▒▒▒▒ █ ██ ▒████ ▒██▒ ██████ ▒████▒
+# ██ ██ ██ ▒▒▒▒ ▒▒ ▒▒▒▒▒▒ ▒▒▒▒
+# ██ ██████████ ██
+# ██ ██ JustEnoughVCS CommandLine
+# ████████████████████████████████ Zsh Plugin
+# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
+
+autoload -Uz add-zsh-hook
+
+##################
+### APPEARANCE ###
+##################
+
+JVCS_VIEW='NORMAL'
+JVCS_PREFIX='['
+JVCS_SPLIT='/'
+JVCS_SUFFIX=']'
+
+###################
+### THEME READS ###
+###################
+
+JVCS_PROMPT_SEGMENT=''
+
+######################
+### INTERNAL STATE ###
+######################
+
+JVCS_DISPLAY=''
+JVCS_WS=''
+JVCS_ACCOUNT=''
+JVCS_SHEET=''
+JVCS_UPSTREAM=''
+
+###################
+### STATE LAYER ###
+###################
+
+jvcs_read_state() {
+ JVCS_WS="$(jv _workspace_dir)"
+ JVCS_ACCOUNT="$(jv _account)"
+ JVCS_SHEET="$(jv _sheet)"
+ JVCS_UPSTREAM="$(jv _upstream)"
+}
+
+##################
+### VIEW LAYER ###
+##################
+
+jvcs_compute_view() {
+ # Must be in a Workspace, otherwise do not display
+ if [[ -z "$JVCS_WS" ]]; then
+ JVCS_DISPLAY=''
+ return
+ fi
+ JVCS_DISPLAY='1'
+}
+
+####################
+### RENDER LAYER ###
+####################
+
+jvcs_render_prompt() {
+ # Only set prompt segment if display is enabled
+ if [[ -n "$JVCS_DISPLAY" ]]; then
+ case "$JVCS_VIEW" in
+ FULL)
+ JVCS_PROMPT_SEGMENT="%{$fg[white]%}${JVCS_PREFIX}${JVCS_UPSTREAM}${JVCS_SPLIT}${JVCS_ACCOUNT}${JVCS_SPLIT}${JVCS_SHEET}${JVCS_SUFFIX} %{$reset_color%}"
+ ;;
+ NORMAL)
+ JVCS_PROMPT_SEGMENT="%{$fg[white]%}${JVCS_PREFIX}${JVCS_ACCOUNT}${JVCS_SPLIT}${JVCS_SHEET}${JVCS_SUFFIX} %{$reset_color%}"
+ ;;
+ SHORT)
+ JVCS_PROMPT_SEGMENT="%{$fg[white]%}${JVCS_PREFIX}${JVCS_SHEET}${JVCS_SUFFIX} %{$reset_color%}"
+ ;;
+ *)
+ JVCS_PROMPT_SEGMENT=''
+ ;;
+ esac
+ else
+ JVCS_PROMPT_SEGMENT=''
+ fi
+}
+
+####################
+### ORCHESTRATOR ###
+####################
+
+jvcs_update() {
+ jvcs_read_state
+ jvcs_compute_view
+ jvcs_render_prompt
+}
+
+#############
+### HOOKS ###
+#############
+
+JVCS_NEED_REFRESH=0
+
+jvcs_preexec() {
+ case "$1" in
+ jv\ status | \
+ jv\ use* | \
+ jv\ as* | \
+ jv\ exit | \
+ jv\ sheet\ use* | \
+ jv\ sheet\ sheet\ exit | \
+ jv\ account\ as*)
+ JVCS_NEED_REFRESH=1
+ ;;
+ esac
+}
+
+jvcs_precmd() {
+ [[ "$JVCS_NEED_REFRESH" -eq 1 ]] || return
+ JVCS_NEED_REFRESH=0
+ jvcs_update
+}
+
+jvcs_chpwd() {
+ jvcs_update
+}
+
+add-zsh-hook preexec jvcs_preexec
+add-zsh-hook precmd jvcs_precmd
+add-zsh-hook chpwd jvcs_chpwd
+
+###############################
+### FALLBACK INITIALIZATION ###
+###############################
+
+jvcs_precmd_init() {
+ [[ -n "${JVCS_INITIALIZED:-}" ]] && return
+ JVCS_INITIALIZED=1
+ jvcs_update
+}
+
+add-zsh-hook precmd jvcs_precmd_init