Improve built in ant completion.
This commit is contained in:
parent
d8d5445edb
commit
f1f03cd9dc
2
CHANGES
2
CHANGES
@ -45,7 +45,7 @@ bash-completion (1.x)
|
|||||||
* Add make --old/new-file, --assume-old/new, --what-if value completions.
|
* Add make --old/new-file, --assume-old/new, --what-if value completions.
|
||||||
* Add smartctl -n/--nocheck completion, add more other value completions.
|
* Add smartctl -n/--nocheck completion, add more other value completions.
|
||||||
* Fix leaking $prev from mkinitrd completion.
|
* 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 ]
|
[ Todd Zullinger ]
|
||||||
* Make yum complete on filenames after install, deplist, update and upgrade
|
* Make yum complete on filenames after install, deplist, update and upgrade
|
||||||
|
40
contrib/ant
40
contrib/ant
@ -13,27 +13,41 @@ _ant()
|
|||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
-buildfile|-f)
|
-buildfile|-file|-f)
|
||||||
_filedir 'xml'
|
_filedir 'xml'
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
-logfile)
|
-logfile|-l)
|
||||||
_filedir
|
_filedir
|
||||||
return 0
|
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
|
esac
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
# relevant options completion
|
COMPREPLY=( $( compgen -W '-help -h -projecthelp -p -version \
|
||||||
COMPREPLY=( $( compgen -W '-help -projecthelp -version -quiet \
|
-diagnostics -quiet -q -verbose -v -debug -d -emacs -e \
|
||||||
-verbose -debug -emacs -logfile -logger \
|
-lib -logfile -l -logger -listener -noinput -buildfile \
|
||||||
-listener -buildfile -f -D -find' -- $cur ) )
|
-file -f -D -keep-going -k -propertyfile -inputhandler \
|
||||||
|
-find -s -nice -nouserlib -noclasspath -autoproxy \
|
||||||
|
-main' -- $cur ) )
|
||||||
else
|
else
|
||||||
# available targets completion
|
# available targets completion
|
||||||
# find which buildfile to use
|
# find which buildfile to use
|
||||||
buildfile=build.xml
|
buildfile=build.xml
|
||||||
for (( i=1; i < COMP_CWORD; i++ )); do
|
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]}
|
buildfile=${COMP_WORDS[i+1]}
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -41,12 +55,12 @@ _ant()
|
|||||||
[ ! -f $buildfile ] && return 0
|
[ ! -f $buildfile ] && return 0
|
||||||
|
|
||||||
# parse buildfile for targets
|
# parse buildfile for targets
|
||||||
COMPREPLY=( $( awk -F'"' '/<target name="/ {print $2}' \
|
# some versions of sed complain if there's no trailing linefeed,
|
||||||
$buildfile | grep "^$cur" )
|
# hence the 2>/dev/null
|
||||||
$( awk -F"'" "/<target name='/ "'{print $2}' \
|
COMPREPLY=( $( compgen -W "$( cat $buildfile | \
|
||||||
$buildfile | grep "^$cur" )
|
tr "'\t\n>" "\" \n" | \
|
||||||
$( awk -F'"' '/<target [^n]/ {if ($1 ~ /name=/) { print $2 } else if ($3 ~ /name=/) {print $4} else if ($5 ~ /name=/) {print $6}}' \
|
sed -ne 's/.*<target .*name="\([^"]*\).*/\1/p' \
|
||||||
$buildfile | grep "^$cur" ) )
|
2>/dev/null )" -- $cur ) )
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
have complete-ant-cmd.pl && \
|
have complete-ant-cmd.pl && \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user