X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=usr_share_grml%2Fzsh%2Ffunctions%2FLookup%2FBackends%2FLOOKUP_be_deb_bts;fp=usr_share_grml%2Fzsh%2Ffunctions%2FLookup%2FBackends%2FLOOKUP_be_deb_bts;h=f171170e7596d56bb48bdddbb5018b635a12eec2;hb=1ee27bd79f2b8eae519f6890bc43f5feca13a261;hp=0000000000000000000000000000000000000000;hpb=9ae0b0c0858f15dc7ec46fbd86660dafc3946695;p=grml-etc-core.git diff --git a/usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_deb_bts b/usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_deb_bts new file mode 100644 index 0000000..f171170 --- /dev/null +++ b/usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_deb_bts @@ -0,0 +1,65 @@ +### vim:ft=zsh:foldmethod=marker +## bugs.debian.org backend for lookup +## Copyright: 2009, Frank Terbeck + +LOOKUP_guard || return 1 +[[ -n ${lookup_describe} ]] && + printf '%s' 'get information about debian bugs by #id' && + return 0 + +local -a comp_args + +LOOKUP_guard -fd LOOKUP_help_${backend} || +function LOOKUP_help_${backend}() { + LOOKUP_guard || return 1 + printf 'usage: %s [-p] \n' ${backend} + printf ' -p go to the bts page of a given package\n' + printf '\n Query Debian[1]'\''s Bug Tracking System[2].\n' + printf '\n By default, this looks up bugs by bug id. In this mode, all non-digit\n' + printf ' characters are automatically stripped off of the query.\n' + printf '\nExamples:\n' + printf ' %% lookup %s 123456\n' ${backend} + printf ' %% lookup %s "#123456"\n' ${backend} + printf ' %% lookup %s -p zsh\n' ${backend} + printf '\n[1] \n' + printf '[2] \n' +} +LOOKUP_help && return 0 + +if [[ -n ${lookup_complete} ]] ; then + comp_args=( + '-p[go to package'\''s bts page]:package:_deb_packages avail' + '*:debian bts query:true' + ) + + _arguments -s -w -A '-*' ${comp_args} && return 0 + _message 'debian bts query' + return 0 +fi + +local mode +local -A opts +local -x QUERY + +mode='id' +lu_parseopts_args=( p bool ) +LOOKUP_parseopts "$@" || return 1 +[[ ${opts[-p]} == 'yes' ]] && mode='package' + +QUERY="${args[*]}" +LOOKUP_query_handler || return 1 +if [[ -z ${QUERY} ]] ; then + LOOKUP_help -f + return 1 +fi + +if [[ ${mode} == 'id' ]] ; then + QUERY="${QUERY//[^0-9]/}" + LOOKUP_encode -q + LOOKUP_browser "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${QUERY}" + return $? +else + LOOKUP_encode -q + LOOKUP_browser "http://bugs.debian.org/${QUERY}" + return $? +fi