diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-11-22 20:19:20 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-11-22 20:19:20 +0800 |
| commit | e579a2e9ffc1e24d30cd117966079c4a6a805fbf (patch) | |
| tree | 7c7ff05e535b77a2a4bf4b4b0af9cd691341e43f /scripts/completion_jv.sh | |
| parent | fcff43f38ea3b83a554452ed8c11b0d295ad9dba (diff) | |
Update sheet align command structure and add completion
Diffstat (limited to 'scripts/completion_jv.sh')
| -rw-r--r-- | scripts/completion_jv.sh | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/scripts/completion_jv.sh b/scripts/completion_jv.sh index 43c8f70..ff600ed 100644 --- a/scripts/completion_jv.sh +++ b/scripts/completion_jv.sh @@ -25,10 +25,10 @@ _jv_completion() { local account_commands="list as add remove movekey mvkey mvk genpub help" # Subcommands - Sheet - local sheet_commands="list use exit make drop help" + local sheet_commands="list use exit make drop help align" # Subcommands - Sheet - local sheet_commands="list use exit make drop help" + local sheet_commands="list use exit make drop help align" # Completion subcommands if [[ $cword -eq 1 ]]; then @@ -97,10 +97,63 @@ _jv_completion() { COMPREPLY=($(compgen -W "$all_sheets" -- "$cur")) fi ;; + "align") + if [[ $cword -eq 3 ]]; then + local align_items="lost moved" + 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" + else + align_operations="local remote confirm $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" + 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" + else + align_operations="local remote confirm $created_items" + fi + + COMPREPLY=($(compgen -W "$align_operations" -- "$cur")) + fi + return 0 + fi + # Completion login if [[ "$subcmd" == "login" ]]; then if [[ $cword -eq 2 ]]; then |
