]> git.pld-linux.org Git - packages/bash-completion.git/commitdiff
- based on ant completion
authorElan Ruusamäe <glen@pld-linux.org>
Sat, 26 Mar 2011 13:32:18 +0000 (13:32 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    phing.sh -> 1.1

phing.sh [new file with mode: 0644]

diff --git a/phing.sh b/phing.sh
new file mode 100644 (file)
index 0000000..393df42
--- /dev/null
+++ b/phing.sh
@@ -0,0 +1,62 @@
+# bash completion for phing
+
+have phing &&
+{
+_phing()
+{
+    local cur prev buildfile i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -buildfile|-file|-f)
+            _filedir 'xml'
+            return 0
+            ;;
+        -logfile)
+            _filedir
+            return 0
+            ;;
+        -logger|-listener|-D|-inputhandler)
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-help -version \
+            -quiet -verbose -debug -logfile -logger -listener \
+            -buildfile -D -inputhandler \
+            -projecthelp \
+            -find' \
+            -- "$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]}" == -@(?(build)file|f) ]]; then
+                buildfile=${COMP_WORDS[i+1]}
+                break
+            fi
+        done
+        [ ! -f $buildfile ] && return 0
+
+        # parse buildfile for targets
+        # some versions of sed complain if there's no trailing linefeed,
+        # hence the 2>/dev/null
+        COMPREPLY=( $( compgen -W "$( cat $buildfile | tr "'\t\n>" "\"  \n" | \
+            sed -ne 's/.*<target .*name="\([^"]*\).*/\1/p' 2>/dev/null )" \
+            -- "$cur" ) )
+        fi
+} &&
+complete -F _phing phing
+}
+
+# Local variables:
+# mode: shell-script
+# sh-basic-offset: 4
+# sh-indent-comment: t
+# indent-tabs-mode: nil
+# End:
+# ex: ts=4 sw=4 et filetype=sh
This page took 0.078689 seconds and 4 git commands to generate.