bash-completion/bash-completion-mock

69 lines
1.9 KiB
Plaintext
Raw Normal View History

# bash completion for mock -*- sh -*-
# TODO: --copyin, --copyout
_mock()
{
local cur prev plugins cfgdir
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
2007-11-16 22:07:07 +00:00
plugins='ccache yum_cache root_cache bind_mount'
cfgdir=/etc/mock
count=0
for i in ${COMP_WORDS[@]} ; do
[ $count -eq $COMP_CWORD ] && break
2007-11-16 22:07:07 +00:00
if [[ "$i" == --configdir ]] ; then
cfgdir="${COMP_WORDS[((count+1))]}"
elif [[ "$i" == --configdir=* ]] ; then
cfgdir=${i/*=/}
fi
count=$((++count))
done
case $prev in
-r)
COMPREPLY=( $( command ls $cfgdir | \
sed -ne 's/^\('$cur'.*\)\.cfg$/\1/p') )
return 0
;;
2007-11-16 22:07:07 +00:00
-@(-help|h))
return 0
;;
esac
2007-11-16 22:07:07 +00:00
# --name=value style option
if [[ "$cur" == *=* ]] ; then
prev=${cur/=*/}
cur=${cur/*=/}
case $prev in
--@(config|result)dir)
_filedir -d
return 0
;;
--@(en|dis)able-plugin)
COMPREPLY=( $( compgen -W "$plugins" -- $cur ) )
return 0
;;
--@(arch|define|with|without|uniqueext|rpmbuild_timeout))
2007-11-16 22:07:07 +00:00
return 0
;;
esac
fi
if [[ "$cur" == -* ]] ; then
COMPREPLY=( $( compgen -W '--version -h --help --rebuild --chroot \
--shell --clean --init --installdeps --install --update \
--orphanskill -r --offline --no-clean --cleanup-after \
--no-cleanup-after --arch= --define= --with= --without= \
--resultdir= --uniqueext= --configdir= --rpmbuild_timeout -v \
--verbose -q --quiet --trace --enable-plugin= --disable-plugin=' \
-- $cur ) )
else
_filedir '?(no)src.rpm'
fi
}
complete -F _mock $filenames mock