[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 14588b849107ce8223e5d400f9dcd6d321326e08

Ville Skyttä ville.skytta at iki.fi
Mon Dec 28 22:10:22 UTC 2009


The following commit has been merged in the master branch:
commit 14588b849107ce8223e5d400f9dcd6d321326e08
Author: Raphaël Droz <gibboris at gmail.com>
Date:   Tue Dec 29 00:10:13 2009 +0200

    Add xsltproc completion (Alioth: #311843).

diff --git a/CHANGES b/CHANGES
index 3634f81..c76677a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -64,6 +64,9 @@ bash-completion (2.x)
   [ Leonard Crestez ]
   * Improve ssh -o suboption completion (Alioth: #312122).
 
+  [ Raphaël Droz ]
+  * Add xsltproc completion (Alioth: #311843).
+
  -- David Paleino <d.paleino at gmail.com>  Sun, 11 Oct 2009 11:11:57 +0200
 
 bash-completion (1.1)
diff --git a/Makefile.am b/Makefile.am
index fc38afd..06309d3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -147,6 +147,7 @@ bashcomp_DATA = contrib/abook \
 		contrib/xmlwf \
 		contrib/xmms \
 		contrib/xrandr \
+		contrib/xsltproc \
 		contrib/xz \
 		contrib/yp-tools \
 		contrib/yum-arch
diff --git a/contrib/xsltproc b/contrib/xsltproc
new file mode 100644
index 0000000..3576f98
--- /dev/null
+++ b/contrib/xsltproc
@@ -0,0 +1,57 @@
+# xsltproc(1) completion
+
+have xsltproc &&
+_xsltproc()
+{
+    local cur prev
+    COMPREPLY=()
+    cur=`_get_cword`
+    prev=`_get_pword`
+
+    case $prev in
+	--output|-o)
+            _filedir
+            return 0
+            ;;
+        # TODO : number only
+        --maxdepth)
+            return 0
+            ;;
+        --encoding)
+            # some aliases removed
+            COMPREPLY=( $( compgen -W "$( iconv -l | sed -e '/^UTF[1378]/d' \
+                -e '/^ISO[0-9_]/d' -e '/^8859/d' -e 's/\/.*//')" -- "$cur" ) )
+            return 0
+            ;;
+        --param|--stringparam)
+            return 0
+            ;;
+        # not really like --writesubtree
+        --path)
+            _filedir -d
+            return 0
+            ;;
+        --writesubtree)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    [[ $COMP_CWORD -gt 2 && `_get_cword '' 2` == --?(string)param ]] && \
+        return 0
+
+    if [[ "$cur" == -* ]]; then
+        _longopt xsltproc
+    else
+	_filedir '@(xsl|xslt|xml)'
+    fi
+} &&
+complete -F _xsltproc -o filenames xsltproc
+
+# 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
diff --git a/test/completion/xsltproc.exp b/test/completion/xsltproc.exp
new file mode 100644
index 0000000..26fabe8
--- /dev/null
+++ b/test/completion/xsltproc.exp
@@ -0,0 +1,3 @@
+if {[assert_bash_type xsltproc]} {
+    source "lib/completions/xsltproc.exp"
+}; # if
diff --git a/test/lib/completions/abook.exp b/test/lib/completions/xsltproc.exp
similarity index 81%
copy from test/lib/completions/abook.exp
copy to test/lib/completions/xsltproc.exp
index 3f4e301..2470c22 100644
--- a/test/lib/completions/abook.exp
+++ b/test/lib/completions/xsltproc.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "abook "
+assert_complete_any "xsltproc "
 
 
 sync_after_int

-- 
bash-completion



More information about the Bash-completion-commits mailing list