dc42e8d488d7b7b5285e71947940c7d6fb19355b

Author
Andrew Janke <andrew@apjanke.net>
Committer
Andrew Janke <andrew@apjanke.net>
Date

Message

jira: add completion

Diff

 1diff --git a/plugins/jira/_jira b/plugins/jira/_jira
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..b0ea658e2f3ac23079fb19166509667407741ae2
 4--- /dev/null
 5+++ b/plugins/jira/_jira
 6@@ -0,0 +1,21 @@
 7+#compdef jira
 8+#autoload
 9+
10+local -a _1st_arguments
11+_1st_arguments=(
12+  'new:create a new issue'
13+  'dashboard:open the dashboard'
14+  'reported:search for issues reported by a user'
15+  'assigned:search for issues assigned to a user'
16+)
17+
18+_arguments -C \
19+  ':command:->command' \
20+  '*::options:->options'
21+
22+case $state in
23+  (command)
24+    _describe -t commands "jira subcommand" _1st_arguments
25+    return
26+   ;;
27+esac
28diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
29index a10feec3e1420a8e675864dadf96b536c7c425a0..89559767f86b684ea0e47a69ea363e94acf11d12 100644
30--- a/plugins/jira/jira.plugin.zsh
31+++ b/plugins/jira/jira.plugin.zsh
32@@ -40,7 +40,7 @@ function jira() {
33   elif [[ -n "${JIRA_URL}" ]]; then
34     jira_url=${JIRA_URL}
35   else
36-    jira_url_help
37+    _jira_url_help
38     return 1
39   fi
40 
41@@ -59,7 +59,7 @@ function jira() {
42     echo "Opening new issue"
43     open_command "${jira_url}/secure/CreateIssue!default.jspa"
44   elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
45-    jira_query $@
46+    _jira_query $@
47   elif [[ "$action" == "dashboard" ]]; then
48     echo "Opening dashboard"
49     open_command "${jira_url}/secure/Dashboard.jspa"
50@@ -82,7 +82,7 @@ function jira() {
51   fi
52 }
53 
54-function jira_url_help() {
55+function _jira_url_help() {
56   cat << EOF
57 JIRA url is not specified anywhere.
58 Valid options, in order of precedence:
59@@ -92,7 +92,7 @@ Valid options, in order of precedence:
60 EOF
61 }
62 
63-function jira_query() {
64+function _jira_query() {
65   local verb="$1"
66   local jira_name lookup preposition query
67   if [[ "${verb}" == "reported" ]]; then