From 44971259d2b63f5267f1e92fbf5867640edc0db8 Mon Sep 17 00:00:00 2001 From: Shane Jaroch Date: Fri, 16 Jan 2026 22:03:29 -0500 Subject: [PATCH] tidy completions --- completions/bash/git-remote-gcrypt | 2 +- completions/fish/git-remote-gcrypt.fish | 7 +++---- completions/zsh/_git-remote-gcrypt | 2 +- utils/gen_docs.sh | 25 ++++++++++++++----------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/completions/bash/git-remote-gcrypt b/completions/bash/git-remote-gcrypt index 6415eaf..5428873 100644 --- a/completions/bash/git-remote-gcrypt +++ b/completions/bash/git-remote-gcrypt @@ -22,7 +22,7 @@ _git_remote_gcrypt() { case "${COMP_WORDS[1]}" in clean) local remotes=$(git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print $1}' | sort -u || :) - COMPREPLY=($(compgen -W "--force Actually --init Allow --hard Override $remotes" -- "$cur")) + COMPREPLY=($(compgen -W "--force --init --hard $remotes" -- "$cur")) return 0 ;; check | stat) diff --git a/completions/fish/git-remote-gcrypt.fish b/completions/fish/git-remote-gcrypt.fish index 52496c1..bdb8d42 100644 --- a/completions/fish/git-remote-gcrypt.fish +++ b/completions/fish/git-remote-gcrypt.fish @@ -13,7 +13,6 @@ complete -c git-remote-gcrypt -n "__fish_seen_subcommand_from check" -a "(git re complete -c git-remote-gcrypt -n "__fish_seen_subcommand_from stat" -a "(git remote 2>/dev/null)" -d 'Git Remote' # Clean flags -complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from clean" -s -force -l Actually -d 'Flag'; -complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from clean" -s -init -l Allow -d 'Flag'; -complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from clean" -s -hard -l Override -d 'Flag'; - +complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from clean" -l force -d 'Flag' +complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from clean" -l init -d 'Flag' +complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from clean" -l hard -d 'Flag' diff --git a/completions/zsh/_git-remote-gcrypt b/completions/zsh/_git-remote-gcrypt index 415c3d1..0b86da0 100644 --- a/completions/zsh/_git-remote-gcrypt +++ b/completions/zsh/_git-remote-gcrypt @@ -14,7 +14,7 @@ _git_remote_gcrypt() { case $line[1] in clean) - _arguments '(--force Actually --init Allow --hard Override)'{--force,Actually,--init,Allow,--hard,Override}'[flag]' \ + _arguments '(--force --init --hard)'{--force,--init,--hard}'[flag]' \ '*:gcrypt URL: _alternative "remotes:gcrypt remote:($(git remote -v 2>/dev/null | grep "gcrypt::" | awk "{print \$1}" | sort -u))" "files:file:_files"' ;; check | stat) diff --git a/utils/gen_docs.sh b/utils/gen_docs.sh index d14b84d..217beda 100755 --- a/utils/gen_docs.sh +++ b/utils/gen_docs.sh @@ -36,9 +36,9 @@ COMMANDS_HELP=$(echo "$RAW_HELP" | sed -n '/^Options:/,$p' | sed 's/^/ /' | s COMMANDS_LIST=$(echo "$RAW_HELP" | awk '/^ [a-z]+ / {print $1}' | grep -vE "^(help|version|capabilities|list|push|fetch)$" | sort | tr '\n' ' ' | sed 's/ $//') # Extract clean flags -# Text: " clean -f, --force Actually delete files..." -# We want: "-f --force -i --init" for Bash -CLEAN_FLAGS_RAW=$(echo "$RAW_HELP" | grep "^ clean -" | awk '{print $2, $3}' | sed 's/,//g') +# Text: " clean --force Actually delete files..." +# We want: "--force --init --hard" +CLEAN_FLAGS_RAW=$(echo "$RAW_HELP" | grep "^ clean -" | awk '{print $2}') CLEAN_FLAGS_BASH=$(echo "$CLEAN_FLAGS_RAW" | tr '\n' ' ' | sed 's/ $//') # For Zsh: we want simple list for now as per plan, user asked for dynamic but safe. @@ -51,25 +51,28 @@ CLEAN_FLAGS_ZSH="" COMMA_FLAGS=$(echo "$CLEAN_FLAGS_BASH" | tr ' ' ',') if [ -n "$CLEAN_FLAGS_BASH" ]; then # zsh _arguments requires format: '(exclusion)'{-f,--long}'[desc]' as ONE string (no spaces) + # Since we only have one flag per line now (long only), exclusion is just itself or list of all? + # Mutually exclusive? Maybe. For now, simple list. + # Actually, with single flags, no need for the {...} brace expansion for aliases. + # Just list them. CLEAN_FLAGS_ZSH="'(${CLEAN_FLAGS_BASH})'{${COMMA_FLAGS}}'[flag]'" else CLEAN_FLAGS_ZSH="" fi -# For Fish -# We need to turn "-f, --force" into: -# complete ... -s f -l force ... CLEAN_FLAGS_FISH="" # Use a loop over the raw lines IFS=" " +newline=" +" +sep="" for line in $CLEAN_FLAGS_RAW; do - # line is like "-f --force" - short=$(echo "$line" | awk '{print $1}' | sed 's/-//') - long=$(echo "$line" | awk '{print $2}' | sed 's/--//') + # line is just "--force" now + long="${line#--}" # Escape quotes if needed (none usually) - CLEAN_FLAGS_FISH="${CLEAN_FLAGS_FISH}complete -c git-remote-gcrypt -f -n \"__fish_seen_subcommand_from clean\" -s $short -l $long -d 'Flag'; -" + CLEAN_FLAGS_FISH="${CLEAN_FLAGS_FISH}${sep}complete -c git-remote-gcrypt -f -n \"__fish_seen_subcommand_from clean\" -l $long -d 'Flag'" + sep="$newline" done unset IFS -- 2.52.0