From e579a2e9ffc1e24d30cd117966079c4a6a805fbf Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 22 Nov 2025 20:19:20 +0800 Subject: Update sheet align command structure and add completion --- scripts/completion_jv.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) (limited to 'scripts') 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 -- cgit