From 578db47c94b2144266c0034dc7cd92958a040e67 Mon Sep 17 00:00:00 2001 From: Shane Jaroch Date: Thu, 8 Jan 2026 18:02:35 -0500 Subject: [PATCH] wip completions --- completions/bash/git-remote-gcrypt | 2 +- completions/fish/git-remote-gcrypt.fish | 14 +++++++------- completions/gen_docs.py | 14 ++++++++------ completions/zsh/_git-remote-gcrypt | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/completions/bash/git-remote-gcrypt b/completions/bash/git-remote-gcrypt index 4e46442..96f4b04 100644 --- a/completions/bash/git-remote-gcrypt +++ b/completions/bash/git-remote-gcrypt @@ -7,7 +7,7 @@ _git_remote_gcrypt() { cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD - 1]}" opts="-h --help -v --version --check" - commands="capabilities check clean fetch list push" + commands="check clean" # 1. First argument: complete commands and global options if [[ $COMP_CWORD -eq 1 ]]; then diff --git a/completions/fish/git-remote-gcrypt.fish b/completions/fish/git-remote-gcrypt.fish index c8f4636..48bc49d 100644 --- a/completions/fish/git-remote-gcrypt.fish +++ b/completions/fish/git-remote-gcrypt.fish @@ -6,15 +6,15 @@ complete -c git-remote-gcrypt -s v -l version -d 'Show version information' complete -c git-remote-gcrypt -l check -d '(Legacy) Check if URL is a gcrypt repository' -r -F # 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 -f -n "not __fish_seen_subcommand_from check clean" -a 'check' -d 'Check if URL is a gcrypt repository' +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -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' +complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from check clean" -s f -l force -d 'Actually delete files during clean' # Git protocol commands -complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'capabilities' -d 'Show git remote helper capabilities' -complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'list' -d 'List refs in remote repository' -complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'push' -d 'Push refs to remote repository' -complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'fetch' -d 'Fetch refs from remote repository' +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -a 'capabilities' -d 'Show git remote helper capabilities' +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -a 'list' -d 'List refs in remote repository' +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -a 'push' -d 'Push refs to remote repository' +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -a 'fetch' -d 'Fetch refs from remote repository' diff --git a/completions/gen_docs.py b/completions/gen_docs.py index 217a731..df7405c 100755 --- a/completions/gen_docs.py +++ b/completions/gen_docs.py @@ -22,10 +22,14 @@ def parse_commands(help_text): capture = False for line in lines: line = line.strip() - if line.startswith("Options:") or line.startswith("Git Protocol Commands"): + + # Filter out what we don't want in tab completion + if line.startswith("Options:"): capture = True continue - if line.startswith("Environment Variables:"): + if line.startswith("Git Protocol Commands") or line.startswith( + "Environment Variables:" + ): capture = False continue @@ -110,10 +114,8 @@ def main(): help_text = extract_help_text(script_path) commands = parse_commands(help_text) - # We always want protocol commands in completions too - comp_commands = sorted( - list(set(commands + ["capabilities", "list", "push", "fetch"])) - ) + # Optional: remove (or add) any custom preferences here + comp_commands = commands print(f"Detected commands: {' '.join(comp_commands)}") diff --git a/completions/zsh/_git-remote-gcrypt b/completions/zsh/_git-remote-gcrypt index 0fe728b..e49259b 100644 --- a/completions/zsh/_git-remote-gcrypt +++ b/completions/zsh/_git-remote-gcrypt @@ -8,7 +8,7 @@ _git_remote_gcrypt() { '(- *)'{-h,--help}'[show help message]' '(- *)'{-v,--version}'[show version information]' '--check[check if URL is a gcrypt repository]:URL:_files' - '1:command:(capabilities check clean fetch list push)' + '1:command:(check clean)' '*::subcommand arguments:->args' ) _arguments -s -S $args -- 2.52.0