diff --git a/CHANGES b/CHANGES index 7d833566..9219de33 100644 --- a/CHANGES +++ b/CHANGES @@ -45,7 +45,7 @@ bash-completion (1.x) * Add make --old/new-file, --assume-old/new, --what-if value completions. * Add smartctl -n/--nocheck completion, add more other value completions. * Fix leaking $prev from mkinitrd completion. - * Split ant completion to contrib/ant. + * Split ant completion to contrib/ant, improve the built in one. [ Todd Zullinger ] * Make yum complete on filenames after install, deplist, update and upgrade diff --git a/contrib/ant b/contrib/ant index a73b6835..8641705c 100644 --- a/contrib/ant +++ b/contrib/ant @@ -13,27 +13,41 @@ _ant() prev=${COMP_WORDS[COMP_CWORD-1]} case "$prev" in - -buildfile|-f) + -buildfile|-file|-f) _filedir 'xml' return 0 ;; - -logfile) + -logfile|-l) _filedir return 0 ;; + -propertyfile) + _filedir properties + return 0 + ;; + -nice) + COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9 10' \ + -- $cur ) ) + return 0 + ;; + -lib|-logger|-listener|-D|-inputhandler|-main) + return 0 + ;; esac if [[ "$cur" == -* ]]; then - # relevant options completion - COMPREPLY=( $( compgen -W '-help -projecthelp -version -quiet \ - -verbose -debug -emacs -logfile -logger \ - -listener -buildfile -f -D -find' -- $cur ) ) + COMPREPLY=( $( compgen -W '-help -h -projecthelp -p -version \ + -diagnostics -quiet -q -verbose -v -debug -d -emacs -e \ + -lib -logfile -l -logger -listener -noinput -buildfile \ + -file -f -D -keep-going -k -propertyfile -inputhandler \ + -find -s -nice -nouserlib -noclasspath -autoproxy \ + -main' -- $cur ) ) else # available targets completion # find which buildfile to use buildfile=build.xml for (( i=1; i < COMP_CWORD; i++ )); do - if [[ "${COMP_WORDS[i]}" == -buildfile ]]; then + if [[ "${COMP_WORDS[i]}" == -@(?(build)file|f) ]]; then buildfile=${COMP_WORDS[i+1]} break fi @@ -41,12 +55,12 @@ _ant() [ ! -f $buildfile ] && return 0 # parse buildfile for targets - COMPREPLY=( $( awk -F'"' '//dev/null + COMPREPLY=( $( compgen -W "$( cat $buildfile | \ + tr "'\t\n>" "\" \n" | \ + sed -ne 's/.*/dev/null )" -- $cur ) ) fi } have complete-ant-cmd.pl && \