]> Nutra Git (v1) - gamesguru/git-remote-gcrypt.git/commitdiff
better
authorShane Jaroch <chown_tee@proton.me>
Thu, 8 Jan 2026 21:44:12 +0000 (16:44 -0500)
committerShane Jaroch <chown_tee@proton.me>
Thu, 8 Jan 2026 21:44:12 +0000 (16:44 -0500)
completions/bash/git-remote-gcrypt
completions/fish/git-remote-gcrypt.fish
completions/zsh/_git-remote-gcrypt
git-remote-gcrypt

index 93bcd1563789fdd6cf91afaaeffe09060c4f038c..4e46442763c64b1e3d65a0031ad2c4941ee6b4a6 100644 (file)
@@ -9,36 +9,37 @@ _git_remote_gcrypt() {
        opts="-h --help -v --version --check"
        commands="capabilities check clean fetch list push"
 
-       # If we're after a subcommand, only offer -h/--help
-       if [[ " $commands " =~ " ${COMP_WORDS[1]:-} " ]]; then
-               COMPREPLY=($(compgen -W "-h --help" -- "$cur"))
+       # 1. First argument: complete commands and global options
+       if [[ $COMP_CWORD -eq 1 ]]; then
+               COMPREPLY=($(compgen -W "$commands $opts" -- "$cur"))
+               if [[ "$cur" == gcrypt::* ]]; then
+                       COMPREPLY+=("$cur")
+               fi
                return 0
        fi
 
-       case "$prev" in
-       clean)
-               COMPREPLY=($(compgen -W "-f --force" -- "$cur"))
-               return 0
-               ;;
-       --check | check)
-               # Complete with gcrypt:: URLs or file paths
-               COMPREPLY=($(compgen -f -- "$cur"))
-               return 0
-               ;;
+       # 2. Handle subcommands
+       case "${COMP_WORDS[1]}" in
+               clean)
+                       local remotes=$(git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print $1}' | sort -u || :)
+                       COMPREPLY=($(compgen -W "-f --force -h --help $remotes" -- "$cur"))
+                       return 0
+                       ;;
+               check|--check)
+                       COMPREPLY=($(compgen -f -- "$cur"))
+                       return 0
+                       ;;
+               capabilities|fetch|list|push)
+                       COMPREPLY=($(compgen -W "-h --help" -- "$cur"))
+                       return 0
+                       ;;
        esac
 
+       # 3. Fallback (global flags if not in a known subcommand?)
        if [[ "$cur" == -* ]]; then
                COMPREPLY=($(compgen -W "$opts" -- "$cur"))
                return 0
        fi
-
-       # Complete with both git protocol commands and flags on first argument
-       COMPREPLY=($(compgen -W "$commands $opts" -- "$cur"))
-
-       # Also complete with gcrypt:: URLs
-       if [[ "$cur" == gcrypt::* ]]; then
-               COMPREPLY+=("$cur")
-       fi
 }
 
 complete -F _git_remote_gcrypt git-remote-gcrypt
index 613c89c3af96eeb28f140e49522a53f2ddd6839c..c8f4636f3c11c8b7e832388694035bc1de72d1e6 100644 (file)
@@ -8,6 +8,7 @@ complete -c git-remote-gcrypt -l check -d '(Legacy) Check if URL is a gcrypt rep
 # Subcommands
 complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'check' -d 'Check if URL is a gcrypt repository'
 complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'clean' -d 'Scan/Clean unencrypted files from remote'
+complete -c git-remote-gcrypt -n "__fish_seen_subcommand_from clean check" -a "(git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print \$1}' | sort -u)" -d 'Gcrypt Remote'
 
 # Clean flags
 complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from capabilities check clean fetch list push" -s f -l force -d 'Actually delete files during clean'
index d8001b1adbd0330363a35fff809474420c42a28e..0fe728bf95518d6dd767a36d3b8d4676c8c6e665 100644 (file)
@@ -17,7 +17,7 @@ _git_remote_gcrypt() {
        clean)
                _arguments \
                        '(-f --force)'{-f,--force}'[actually delete files]' \
-                       '*:gcrypt URL:'
+                       '*:gcrypt URL: _alternative "remotes:gcrypt remote:($(git remote -v 2>/dev/null | grep "gcrypt::" | awk "{print \$1}" | sort -u))" "files:file:_files"'
                ;;
        check)
                _arguments \
index a71c53fafa3f635c41a6a4de32a0b664937df7f0..483705e5bb3a30944ed2ad2aa529dc89d1f2609c 100755 (executable)
@@ -1390,10 +1390,9 @@ elif [ "$NAME" = "gcrypt-clean" ]; then
        xecho "$bad_files" | sed 's/^/  /' >&2
 
        if isnull "$FORCE_CLEAN"; then
-               echo_info ""
                echo_info "NOTE: This is a scan of unencrypted files on the remote."
-               echo_info "To actually delete these files, use: git-remote-gcrypt clean $URL --force"
-               echo_info ""
+               echo_info "To actually delete these files, use:"
+               echo_info "   git-remote-gcrypt clean $URL --force"
                CLEAN_FINAL "$URL"
                git remote remove "$NAME" 2>/dev/null || true
                exit 0