70 lines
2.0 KiB
Plaintext
Raw Normal View History

# bash completion for mock -*- shell-script -*-
# Use of this file is deprecated. Upstream completion is available in
# mock > 1.1.0, use that instead.
2009-05-31 23:52:47 +03:00
_mock()
{
local cur prev words cword split
_init_completion -s || return
2009-05-31 23:52:47 +03:00
local plugins='tmpfs root_cache yum_cache bind_mount ccache'
local cfgdir=/etc/mock count=0 i
2009-05-31 23:52:47 +03:00
for i in "${words[@]}" ; do
[ $count -eq $cword ] && break
2009-10-04 19:42:50 +02:00
if [[ "$i" == --configdir ]] ; then
cfgdir="${words[((count+1))]}"
2009-10-04 19:42:50 +02:00
elif [[ "$i" == --configdir=* ]] ; then
cfgdir=${i/*=/}
fi
count=$((++count))
done
2009-05-31 23:52:47 +03:00
2009-10-04 19:42:50 +02:00
case $prev in
2010-10-24 12:37:22 +03:00
-h|--help|--copyin|--copyout|--arch|-D|--define|--with|--without|\
--uniqueext|--rpmbuild_timeout|--sources|--cwd)
2009-10-04 19:42:50 +02:00
return 0
;;
-r|--root)
COMPREPLY=( $( compgen -W "$( command ls $cfgdir )" -- $cur ) )
COMPREPLY=( ${COMPREPLY[@]/%.cfg/} )
return 0
;;
--configdir|--resultdir)
2009-10-04 19:42:50 +02:00
_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 | \
2009-11-03 22:04:46 +02:00
sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p' )" \
2009-10-04 19:42:50 +02:00
-- "$cur" ) )
return 0
;;
--enable-plugin|--disable-plugin)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W "$plugins" -- "$cur" ) )
return 0
;;
esac
2009-05-31 23:52:47 +03:00
2009-10-04 19:42:50 +02:00
$split && return 0
2009-05-31 23:52:47 +03:00
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]] ; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
2009-10-04 19:42:50 +02:00
else
_filedir '@(?(no)src.r|s)pm'
2009-10-04 19:42:50 +02:00
fi
2009-05-31 23:52:47 +03:00
} &&
complete -F _mock mock
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh