The following commit has been merged in the master branch:
commit 508a88e6c0851790831f37c42270e869e44308c0
Author: Ville Skyttä <[email protected]>
Date:   Sun May 31 23:52:47 2009 +0300

    Add mock completion.

diff --git a/CHANGES b/CHANGES
index ee377b0..e690f90 100644
--- a/CHANGES
+++ b/CHANGES
@@ -56,6 +56,7 @@ bash-completion (1.x)
   * Split reportbug and querybts completions to contrib/reportbug.
   * Remove debug output noise from quotaon completion.
   * Split Linux wireless tools completion to contrib/wireless-tools.
+  * Add mock completion.
 
   [ Todd Zullinger ]
   * Make yum complete on filenames after install, deplist, update and upgrade
diff --git a/Makefile.am b/Makefile.am
index 1c78d37..d73b912 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -55,6 +55,7 @@ bashcomp_DATA = contrib/ant \
                contrib/mcrypt \
                contrib/minicom \
                contrib/mkinitrd \
+               contrib/mock \
                contrib/modules \
                contrib/monodevelop \
                contrib/mplayer \
diff --git a/contrib/mock b/contrib/mock
new file mode 100644
index 0000000..933d531
--- /dev/null
+++ b/contrib/mock
@@ -0,0 +1,78 @@
+# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
+# ex: ts=8 sw=8 noet filetype=sh
+#
+# bash completion for mock
+
+have mock &&
+_mock()
+{
+       local cur prev plugins cfgdir split=false
+
+       COMPREPLY=()
+       cur=`_get_cword`
+       prev=${COMP_WORDS[COMP_CWORD-1]}
+       plugins='tmpfs root_cache yum_cache bind_mount ccache'
+       cfgdir=/etc/mock
+
+       count=0
+       for i in "${comp_wor...@]}" ; do
+               [ $count -eq $COMP_CWORD ] && break
+               if [[ "$i" == --configdir ]] ; then
+                       cfgdir="${COMP_WORDS[((count+1))]}"
+               elif [[ "$i" == --configdir=* ]] ; then
+                       cfgdir=${i/*=/}
+               fi
+               count=$((++count))
+       done
+
+       _split_longopt && split=true
+
+       case $prev in
+               
-@(h|-help|-copy@(in|out)|-arch|D|-define|-with?(out)|-uniqueext|-rpmbuild_timeout|-sources|-cwd))
+                       return 0
+                       ;;
+               -r|--root)
+                       COMPREPLY=( $( command ls $cfgdir | \
+                               sed -ne 's/^\('$cur'.*\)\.cfg$/\1/p') )
+                       return 0
+                       ;;
+               --@(config|result)dir)
+                       _filedir -d
+                       return 0
+                       ;;
+               --spec)
+                       _filedir spec
+                       return 0
+                       ;;
+               --target)
+                       # Yep, compatible archs, not compatible build archs
+                       # (e.g. ix86 chroot builds in x86_64 mock host)
+                       # This would actually depend on what the target root
+                       # can be used to build for...
+                       COMPREPLY=( $( compgen -W "$( command rpm --showrc | 
sed -ne 's/^\s*compatible\s\+archs\s*:\s*\(.*\)/\1/i p' )" -- $cur ) )
+                       return 0
+                       ;;
+               --@(en|dis)able-plugin)
+                       COMPREPLY=( $( compgen -W "$plugins" -- $cur ) )
+                       return 0
+                       ;;
+       esac
+
+       $split && return 0
+
+       if [[ "$cur" == -* ]] ; then
+               COMPREPLY=( $( compgen -W '--version -h --help --rebuild \
+                       --buildsrpm --shell --chroot --clean --init \
+                       --installdeps --install --update --orphanskill \
+                       --copyin --copyout -r --root --offline --no-clean \
+                       --cleanup-after --no-cleanup-after --arch --target \
+                       -D --define --with --without --resultdir --uniqueext \
+                       --configdir --rpmbuild_timeout --unpriv --cwd --spec \
+                       --sources -v --verbose -q --quiet --trace \
+                       --enable-plugin --disable-plugin --print-root-path' \
+                       -- $cur ) )
+       else
+               _filedir '?(no)src.rpm'
+       fi
+} &&
+complete -F _mock $filenames mock

-- 
bash-completion

_______________________________________________
Bash-completion-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/bash-completion-commits

Reply via email to