Created
August 12, 2011 06:13
-
-
Save mathieuk/1141556 to your computer and use it in GitHub Desktop.
Bash autocompletion function for the 'phpunit --filter' command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shopt -s progcomp | |
_testnames() | |
{ | |
local cur prev opts base | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opts="--filter" | |
if [[ $cur == -* || $prev == -* ]]; then | |
case "${prev}" in | |
"--filter") | |
local result=$(find ./ -name "*Test.php" | xargs egrep -hr -E 'function +test[A-Za-z0-9]*' -o | sed 's/function[ ]*//') | |
COMPREPLY=( $(compgen -W "${result}" -- ${cur}) ) | |
return 0 | |
esac | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
return 0 | |
else | |
COMPREPLY=( $(compgen -f -X "*Test.php" -- ${cur}) ) | |
fi | |
return 0 | |
} | |
complete -d -X '.[^./]*' -F _testnames phpunit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment