Fix completion after a command-line flag.

Before:
  yadm checkout -f <TAB>  # Completes filenames.
  yadm checkout --yadm-dir <TAB>  # Completes filenames.

After:
  yadm checkout -f <TAB>  # Completes branch names.
  yadm checkout --yadm-dir <TAB>  # Completes filenames.
pull/194/head
David Mandelberg 5 years ago committed by Tim Byrne
parent 09a018ea5a
commit 60e0fbbf42
No known key found for this signature in database
GPG Key ID: 14DB4FC2465A4B12

@ -60,15 +60,17 @@ if declare -F _git > /dev/null; then
;; ;;
esac esac
local yadm_switches=( $(yadm introspect switches 2>/dev/null) )
# this condition is so files are completed properly for --yadm-xxx options # this condition is so files are completed properly for --yadm-xxx options
if [[ ! "$penultimate" =~ ^- ]]; then if [[ " ${yadm_switches[*]} " != *" $penultimate "* ]]; then
# TODO: somehow solve the problem with [--yadm-xxx option] being # TODO: somehow solve the problem with [--yadm-xxx option] being
# incompatible with what git expects, namely [--arg=option] # incompatible with what git expects, namely [--arg=option]
_git _git
fi fi
if [[ "$current" =~ ^- ]]; then if [[ "$current" =~ ^- ]]; then
local matching local matching
matching=$(compgen -W "$(yadm introspect switches 2>/dev/null)" -- "$current") matching=$(compgen -W "${yadm_switches[*]}" -- "$current")
__gitcompappend "$matching" __gitcompappend "$matching"
fi fi

Loading…
Cancel
Save