Add zsh-lookup sub-system
[grml-etc-core.git] / usr_share_grml / zsh / functions / Lookup / Backends / LOOKUP_be_deb_pts
diff --git a/usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_deb_pts b/usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_deb_pts
new file mode 100644 (file)
index 0000000..9fed264
--- /dev/null
@@ -0,0 +1,43 @@
+### vim:ft=zsh:foldmethod=marker
+## packages.qa.debian.org backend for lookup
+## Copyright: 2009, Frank Terbeck <ft@bewatermyfriend.org>
+
+LOOKUP_guard || return 1
+[[ -n ${lookup_describe} ]] &&
+    printf '%s' 'debian PTS information about a package' &&
+    return 0
+
+local -a comp_args
+
+LOOKUP_guard -fd LOOKUP_help_${backend} ||
+function LOOKUP_help_${backend}() {
+    LOOKUP_guard || return 1
+    printf 'usage: %s <package>\n' ${backend}
+    printf '\n Warps you to a package'\''s page in Debian[1]'\''s Package\n'
+    printf ' Tracking System[2].\n'
+    printf '\nExamples\n'
+    printf ' %% lookup %s wesnoth\n' ${backend}
+    printf ' %% lookup %s zsh\n' ${backend}
+    printf '\n[1] <http://www.debian.org>\n'
+    printf '[2] <http://packages.qa.debian.org>\n'
+}
+LOOKUP_help && return 0
+
+if [[ -n ${lookup_complete} ]] ; then
+    _message 'debian package'
+    _deb_packages avail
+    return 0
+fi
+
+local -x QUERY
+
+QUERY="$*"
+LOOKUP_query_handler || return 1
+if [[ -z ${QUERY} ]] ; then
+    LOOKUP_help -f
+    return 1
+fi
+
+LOOKUP_encode -q
+LOOKUP_browser "http://packages.qa.debian.org/${QUERY}"
+return $?