abf-console-client-src/bash_autocomplete

144 lines
2.7 KiB
Bash
Raw Normal View History

2012-09-25 16:44:40 +04:00
# bash-completion add-on for rpmlint
# http://bash-completion.alioth.debian.org/
2012-10-25 15:26:22 +04:00
__abf_opts()
2012-09-25 16:44:40 +04:00
{
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${@}" -- "${cur}") )
return 0
fi
}
2012-10-25 15:26:22 +04:00
__abf_get()
2012-09-25 16:44:40 +04:00
{
2012-10-25 15:26:22 +04:00
__abf_opts "--branch"
2012-09-25 16:44:40 +04:00
}
2012-10-25 15:26:22 +04:00
__abf_put()
2012-09-25 16:44:40 +04:00
{
2012-10-25 15:26:22 +04:00
__abf_opts ""
2012-09-25 16:44:40 +04:00
}
2012-10-25 15:26:22 +04:00
__abf_show()
2012-09-25 16:44:40 +04:00
{
2012-10-25 15:26:22 +04:00
__abf_opts "--project"
shows="build-repos build-platforms save-to-repos save-to-platforms"
if [[ ${cur} != -* ]] ; then
if [[ ${prev} == -* ]] ; then
return 0;
fi
COMPREPLY=( $(compgen -W "${shows}" -- "${cur}") )
return 0
fi
}
__abf_locate()
{
__abf_opts "--project --directory"
actions="update update-recursive"
if [[ ${cur} != -* ]] ; then
if [[ ${prev} == -* ]] ; then
return 0;
fi
COMPREPLY=( $(compgen -W "${actions}" -- "${cur}") )
return 0
fi
2012-09-25 16:44:40 +04:00
}
2012-10-25 15:26:22 +04:00
__abf_build()
2012-09-25 16:44:40 +04:00
{
2012-10-25 15:26:22 +04:00
__abf_opts "--branch --tag --commit --target-platform --arch --repository --save-to-repository --auto-publish --update-type --skip-spec-check"
update_types="security bugfix enhancement recommended newpackage"
if [ ${prev} == -r ] || [ ${prev} == --repository ] ; then
COMPREPLY=( $(compgen -W "`abf-local show build-repos`" -- "${cur}") )
return 0
fi
if [ ${prev} == -s ] || [ ${prev} == --save-to-repository ] ; then
proj=""
next=0
for i in ${COMP_WORDS[@]}
do
if [[ $next == 1 ]] ; then
proj=$i;
next=0;
fi
if [[ "$i" == "-p" || "$i" == "--project" ]] ; then
next=1;
fi;
done
if [ -n "${proj}" ] ; then
COMPREPLY=( $(compgen -W "`abf-local show save-to-repos -p ${proj}`" -- "${cur}") )
fi
return 0
fi
if [ ${prev} == --update-type ] ; then
COMPREPLY=( $(compgen -W "${update_types}" -- "${cur}") )
return 0
fi
2012-09-25 16:44:40 +04:00
}
2012-10-25 15:26:22 +04:00
__abf_publish()
2012-09-25 16:44:40 +04:00
{
2012-10-25 15:26:22 +04:00
__abf_opts "--pack"
2012-09-25 16:44:40 +04:00
}
2012-10-25 15:26:22 +04:00
__abf_backport()
{
__abf_opts "--pack"
if [[ ${cur} != -* ]] ; then
branches=`git branch --no-color | sed 's/^..//' | xargs echo`
COMPREPLY=( $(compgen -W "${branches}" -- "${cur}") )
return 0
fi
}
2012-09-25 16:44:40 +04:00
2012-10-25 15:26:22 +04:00
__abf_buildstatus()
{
__abf_opts ""
}
__abf_help()
{
__abf_opts ""
}
__abf()
2012-09-25 16:44:40 +04:00
{
local opts modes
2012-10-25 15:26:22 +04:00
modes="help get put show build publish backport buildstatus locate"
2012-09-25 16:44:40 +04:00
COMPREPLY=()
mode="${COMP_WORDS[1]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cur="${COMP_WORDS[COMP_CWORD]}"
2012-10-25 15:26:22 +04:00
if [ "$COMP_CWORD" == "1" ] || ( [ "$COMP_CWORD" == "2" ] && [ "$mode" == "help" ] ); then
2012-09-25 16:44:40 +04:00
COMPREPLY=( $(compgen -W "${modes}" -- ${cur}) )
return 0
fi
2012-10-25 15:26:22 +04:00
for i in ${modes}
do
if [[ $i == $mode ]] ; then
eval __abf_${i};
fi
done
2012-09-25 16:44:40 +04:00
}
2012-10-25 15:26:22 +04:00
complete -F __abf abf
2012-09-25 16:44:40 +04:00