2005-11-28 20:26:32 +00:00
|
|
|
# bash completion for mock -*- sh -*-
|
|
|
|
|
2007-12-30 22:23:36 +00:00
|
|
|
# TODO: --copyin, --copyout
|
|
|
|
|
2005-11-28 20:26:32 +00:00
|
|
|
_mock()
|
|
|
|
{
|
2007-12-30 22:23:36 +00:00
|
|
|
local cur prev plugins cfgdir
|
2005-11-28 20:26:32 +00:00
|
|
|
|
|
|
|
COMPREPLY=()
|
2009-01-06 18:44:43 +00:00
|
|
|
cur=`_get_cword`
|
2005-11-28 20:26:32 +00:00
|
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
2007-11-16 22:07:07 +00:00
|
|
|
plugins='ccache yum_cache root_cache bind_mount'
|
2006-08-30 21:27:32 +00:00
|
|
|
cfgdir=/etc/mock
|
|
|
|
|
|
|
|
count=0
|
2009-01-06 18:44:43 +00:00
|
|
|
for i in "${COMP_WORDS[@]}" ; do
|
2006-08-30 21:27:32 +00:00
|
|
|
[ $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
|
2006-08-30 21:27:32 +00:00
|
|
|
count=$((++count))
|
|
|
|
done
|
2005-11-28 20:26:32 +00:00
|
|
|
|
|
|
|
case $prev in
|
2009-01-06 18:44:43 +00:00
|
|
|
-@(-root|r))
|
2006-08-30 21:27:32 +00:00
|
|
|
COMPREPLY=( $( command ls $cfgdir | \
|
2005-11-28 20:26:32 +00:00
|
|
|
sed -ne 's/^\('$cur'.*\)\.cfg$/\1/p') )
|
|
|
|
return 0
|
|
|
|
;;
|
2007-11-16 22:07:07 +00:00
|
|
|
-@(-help|h))
|
2005-11-28 20:26:32 +00:00
|
|
|
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
|
|
|
|
;;
|
2009-01-06 18:44:43 +00:00
|
|
|
--@(arch|target|define|with|without|uniqueext|rpmbuild_timeout|cwd))
|
2007-11-16 22:07:07 +00:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2005-11-28 20:26:32 +00:00
|
|
|
if [[ "$cur" == -* ]] ; then
|
2009-01-06 18:44:43 +00:00
|
|
|
COMPREPLY=( $( compgen -W '--version -h --help --rebuild --shell \
|
|
|
|
--chroot --clean --init --installdeps --install --update \
|
|
|
|
--orphanskill -r --root= --offline --no-clean --cleanup-after \
|
|
|
|
--no-cleanup-after --arch= --target= -D --define= --with= \
|
|
|
|
--without= --resultdir= --uniqueext= --configdir= \
|
|
|
|
--rpmbuild_timeout --unpriv --cwd= -v --verbose -q --quiet \
|
|
|
|
--trace --enable-plugin= --disable-plugin= --print-root-path' \
|
2007-12-30 22:23:36 +00:00
|
|
|
-- $cur ) )
|
2005-11-28 20:26:32 +00:00
|
|
|
else
|
|
|
|
_filedir '?(no)src.rpm'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
complete -F _mock $filenames mock
|