# 2. Handle subcommands
case "${COMP_WORDS[1]}" in
clean)
- local remotes=$(git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print $1}' | sort -u || :
+ local remotes=$(git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print $1}' | sort -u || :)
COMPREPLY=($(compgen -W " $remotes" -- "$cur"))
return 0
;;
check)
- local remotes=$(git remote 2>/dev/null || :
+ local remotes=$(git remote 2>/dev/null || :)
COMPREPLY=($(compgen -W "$remotes" -- "$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 || :
+ local remotes=$(git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print $1}' | sort -u || :)
COMPREPLY=($(compgen -W "{clean_flags_bash} $remotes" -- "$cur"))
return 0
;;
check)
- local remotes=$(git remote 2>/dev/null || :
+ local remotes=$(git remote 2>/dev/null || :)
COMPREPLY=($(compgen -W "$remotes" -- "$cur"))
return 0
;;
case $line[1] in
clean)
_arguments \
- {clean_flags_zsh} \
'*:gcrypt URL: _alternative "remotes:gcrypt remote:($(git remote -v 2>/dev/null | grep "gcrypt::" | awk "{print \$1}" | sort -u))" "files:file:_files"'
;;
check)
case $line[1] in
clean)
_arguments \
- '()' {} '[flag]' \
'*:gcrypt URL: _alternative "remotes:gcrypt remote:($(git remote -v 2>/dev/null | grep "gcrypt::" | awk "{print \$1}" | sort -u))" "files:file:_files"'
;;
check)
CLEAN_FLAGS_ZSH=""
# We'll just provide the flags as a list for _arguments
# ZSH format roughly: '(-f --force)'{-f,--force}'[desc]'
-# Let's simplify and just pass the flags for now to match the user's "native completion" request without over-engineering the parsing in shell.
-# We will just list them.
+# Only generate if there are actual flags
COMMA_FLAGS=$(echo "$CLEAN_FLAGS_BASH" | tr ' ' ',')
-CLEAN_FLAGS_ZSH="'(${CLEAN_FLAGS_BASH})' {${COMMA_FLAGS}} '[flag]'"
+if [ -n "$CLEAN_FLAGS_BASH" ]; then
+ CLEAN_FLAGS_ZSH="'(${CLEAN_FLAGS_BASH})' {${COMMA_FLAGS}} '[flag]'"
+else
+ CLEAN_FLAGS_ZSH=""
+fi
# For Fish
# We need to turn "-f, --force" into: