Sync zsh-lookup with upstream
authorFrank Terbeck <ft@grml.org>
Fri, 5 Nov 2010 08:34:16 +0000 (09:34 +0100)
committerFrank Terbeck <ft@grml.org>
Fri, 5 Nov 2010 08:36:10 +0000 (09:36 +0100)
...adding grml_bts backend.

usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_grml_bts [new file with mode: 0644]

diff --git a/usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_grml_bts b/usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_grml_bts
new file mode 100644 (file)
index 0000000..619ddb7
--- /dev/null
@@ -0,0 +1,46 @@
+### vim:ft=zsh:foldmethod=marker
+## bts.grml.org backend for lookup
+## Copyright: 2010, Frank Terbeck <ft@bewatermyfriend.org>
+
+LOOKUP_guard || return 1
+[[ -n ${lookup_describe} ]] &&
+    printf '%s' 'bts.grml.org bug lookups' &&
+    return 0
+
+LOOKUP_guard -fd LOOKUP_help_${backend} ||
+function LOOKUP_help_${backend}() {
+    LOOKUP_guard || return 1
+    printf 'usage: %s <bug-id>\n' ${backend}
+    printf '\n Query grml[1]'\''s Bug Tracking System[2].\n'
+    printf '\n This looks up bugs by bug id in grml'\''s BTS. In this mode, all\n'
+    printf ' non-digit characters are automatically stripped off of the query.\n'
+    printf '\nExamples:\n'
+    printf ' %% lookup %s 123\n' ${backend}
+    printf ' %% lookup %s "#123"\n' ${backend}
+    printf '\n[1] <http://grml.org>\n'
+    printf '[2] <http://bts.grml.org>\n'
+}
+LOOKUP_help && return 0
+
+local -x QUERY
+local -a comp_args
+
+if [[ -n ${lookup_complete} ]] ; then
+    comp_args=( '*:grml bts query:true' )
+
+    _arguments -s -w -A '-*' ${comp_args} && return 0
+    _message 'grml bts query'
+    return 0
+fi
+
+QUERY="$*"
+LOOKUP_query_handler || return 1
+QUERY="${QUERY//[^0-9]/}"
+if [[ -z ${QUERY} ]] ; then
+    LOOKUP_help -f
+    return 1
+fi
+
+LOOKUP_encode -q
+LOOKUP_browser "http://bts.grml.org/grml/issue${QUERY}"
+return $?