1 ### vim:ft=zsh:foldmethod=marker
2 ## bugs.debian.org backend for lookup
3 ## Copyright: 2009, Frank Terbeck <ft@bewatermyfriend.org>
5 LOOKUP_guard || return 1
6 [[ -n ${lookup_describe} ]] &&
7 printf '%s' 'get information about debian bugs by #id' &&
12 LOOKUP_guard -fd LOOKUP_help_${backend} ||
13 function LOOKUP_help_${backend}() {
14 LOOKUP_guard || return 1
15 printf 'usage: %s [-p] <query>\n' ${backend}
16 printf ' -p go to the bts page of a given package\n'
17 printf '\n Query Debian[1]'\''s Bug Tracking System[2].\n'
18 printf '\n By default, this looks up bugs by bug id. In this mode, all non-digit\n'
19 printf ' characters are automatically stripped off of the query.\n'
20 printf '\nExamples:\n'
21 printf ' %% lookup %s 123456\n' ${backend}
22 printf ' %% lookup %s "#123456"\n' ${backend}
23 printf ' %% lookup %s -p zsh\n' ${backend}
24 printf '\n[1] <http://www.debian.org>\n'
25 printf '[2] <http://bugs.debian.org>\n'
27 LOOKUP_help && return 0
29 if [[ -n ${lookup_complete} ]] ; then
31 '-p[go to package'\''s bts page]:package:_deb_packages avail'
32 '*:debian bts query:true'
35 _arguments -s -w -A '-*' ${comp_args} && return 0
36 _message 'debian bts query'
45 lu_parseopts_args=( p bool )
46 LOOKUP_parseopts "$@" || return 1
47 [[ ${opts[-p]} == 'yes' ]] && mode='package'
50 LOOKUP_query_handler || return 1
51 if [[ -z ${QUERY} ]] ; then
56 if [[ ${mode} == 'id' ]] ; then
57 QUERY="${QUERY//[^0-9]/}"
59 LOOKUP_browser "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${QUERY}"
63 LOOKUP_browser "http://bugs.debian.org/${QUERY}"