From 80182975a4e8bf5b6afe48d212f1b99a6a88a215 Mon Sep 17 00:00:00 2001 From: Daniel Platz Date: Fri, 20 Jan 2017 19:43:44 +0100 Subject: [PATCH] Enhanced handling for ant autocomplete. Instead of assuming a build.xml, now -f can provide an alternative ant .xml file. --- plugins/ant/ant.plugin.zsh | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/plugins/ant/ant.plugin.zsh b/plugins/ant/ant.plugin.zsh index 0b738c94..eb4312a3 100644 --- a/plugins/ant/ant.plugin.zsh +++ b/plugins/ant/ant.plugin.zsh @@ -1,16 +1,33 @@ _ant_does_target_list_need_generating () { - [ ! -f .ant_targets ] && return 0; - [ build.xml -nt .ant_targets ] && return 0; - return 1; + local build_file=$1 + [ ! -f .ant_targets ] && return 0; + [ $build_file -nt .ant_targets ] && return 0; + return 1; } _ant () { - if [ -f build.xml ]; then - if _ant_does_target_list_need_generating; then - ant -p | awk -F " " 'NR > 5 { print lastTarget }{lastTarget = $1}' > .ant_targets - fi - compadd -- `cat .ant_targets` - fi + _arguments ':target:->target' '-f[build-file]:filename:->files' + + case "$state" in + files) + compadd -- $(grep -l --color=never " 5 { print lastTarget }{lastTarget = $1}' > .ant_targets + fi + compadd -- $(cat .ant_targets) + fi + #_values 'target' a b c d e + ;; + esac } compdef _ant ant