summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-05 15:09:57 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-05 15:09:57 +0800
commit4c54c3282b5980551179da5c7f7416359ad2ded9 (patch)
tree8fe05b7ffcd09fa66782d2908829f31eeb044bf7 /scripts
parent5c4e1b0f94fcf61d44b4d0ba86f54dbde98c31fc (diff)
Add share command with subcommands and completion supportMVP
The share command now supports `list`, `see`, and merging operations with conflict resolution modes (--safe, --skip, --overwrite, --reject). Updated help documentation in both English and Chinese locales, and added Bash and PowerShell completion scripts.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/completions/bash/completion_jv.sh36
-rw-r--r--scripts/completions/powershell/completion_jv.ps135
2 files changed, 69 insertions, 2 deletions
diff --git a/scripts/completions/bash/completion_jv.sh b/scripts/completions/bash/completion_jv.sh
index 4023e42..364df9d 100644
--- a/scripts/completions/bash/completion_jv.sh
+++ b/scripts/completions/bash/completion_jv.sh
@@ -18,7 +18,7 @@ _jv_completion() {
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"
+ jump align info share"
# Subcommands - Account
local account_commands="list as add remove movekey mvkey mvk genpub help"
@@ -157,6 +157,40 @@ _jv_completion() {
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
diff --git a/scripts/completions/powershell/completion_jv.ps1 b/scripts/completions/powershell/completion_jv.ps1
index 0c854e3..84ba01a 100644
--- a/scripts/completions/powershell/completion_jv.ps1
+++ b/scripts/completions/powershell/completion_jv.ps1
@@ -16,7 +16,7 @@ Register-ArgumentCompleter -Native -CommandName jv -ScriptBlock {
"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"
+ "jump", "align", "info", "share"
)
# Account subcommands
@@ -175,6 +175,39 @@ Register-ArgumentCompleter -Native -CommandName jv -ScriptBlock {
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" {