_ant 419 B

12345678910111213141516171819202122
  1. #compdef ant
  2. _ant_does_target_list_need_generating () {
  3. [[ ! -f .ant_targets ]] && return 0
  4. [[ build.xml -nt .ant_targets ]] && return 0
  5. return 1
  6. }
  7. _ant () {
  8. if [[ ! -f build.xml ]]; then
  9. return
  10. fi
  11. if ! _ant_does_target_list_need_generating; then
  12. return
  13. fi
  14. ant -p | awk -F " " 'NR > 5 { print lastTarget } { lastTarget = $1 }' >| .ant_targets
  15. compadd -- "$(cat .ant_targets)"
  16. }
  17. _ant "$@"