7647c79bae1542b5f4dddc85b16058df7f83fc6c

Author
Jim Weller <31997291+jimweller@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(jira): add help/usage cmd (#12293)

Co-authored-by: Carlo Sala <carlosalag@protonmail.com>

Diff

 1diff --git a/plugins/jira/README.md b/plugins/jira/README.md
 2index d78ea15a45e74a589519c44748ffaf7e317be0f5..b1d8a8bc64035938ef9765f0180bb7b76b603198 100644
 3--- a/plugins/jira/README.md
 4+++ b/plugins/jira/README.md
 5@@ -16,18 +16,21 @@ This plugin supplies one command, `jira`, through which all its features are exp
 6 
 7 ## Commands
 8 
 9+`jira help` or `jira usage` will print the below usage instructions
10+
11 | Command       | Description                                               |
12 | :------------ | :-------------------------------------------------------- |
13 | `jira`        | Performs the default action                               |
14 | `jira new`    | Opens a new Jira issue dialogue                           |
15 | `jira ABC-123`   | Opens an existing issue                                |
16 | `jira ABC-123 m` | Opens an existing issue for adding a comment           |
17-| `jira dashboard [rapid_view]` |  # opens your JIRA dashboard              |
18+| `jira dashboard [rapid_view]` |  Opens your JIRA dashboard              |
19 | `jira mine`   | Queries for your own issues                               |
20 | `jira tempo`  | Opens your JIRA Tempo                                     |
21 | `jira reported [username]`  | Queries for issues reported by a user       |
22 | `jira assigned [username]`  | Queries for issues assigned to a user       |
23 | `jira branch` | Opens an existing issue matching the current branch name  |
24+| `jira help` | Prints usage instructions  |
25 
26 
27 ### Jira Branch usage notes
28diff --git a/plugins/jira/_jira b/plugins/jira/_jira
29index 0e37b7e9d39b55f7c85c766839bf4a47f3fb0d04..5f7dcd09d62ce6c4903b0d7ac21284e72b18f414 100644
30--- a/plugins/jira/_jira
31+++ b/plugins/jira/_jira
32@@ -11,6 +11,7 @@ _1st_arguments=(
33   'assigned:search for issues assigned to a user'
34   'branch:open the issue named after the git branch of the current directory'
35   'dumpconfig:display effective jira configuration'
36+  'help:print usage help to stdout'
37 )
38 
39 _arguments -C \
40diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
41index b6ee9f100d105784247add0ae8a536f1fe72031c..9bcf4cc7b07fb5d46add4cc1467f935d4a32506a 100644
42--- a/plugins/jira/jira.plugin.zsh
43+++ b/plugins/jira/jira.plugin.zsh
44@@ -2,6 +2,21 @@
45 #
46 # See README.md for details
47 
48+function _jira_usage() {
49+cat <<EOF
50+jira                            Performs the default action
51+jira new                        Opens a new Jira issue dialogue
52+jira ABC-123                    Opens an existing issue
53+jira ABC-123 m                  Opens an existing issue for adding a comment
54+jira dashboard [rapid_view]     Opens your JIRA dashboard
55+jira mine                       Queries for your own issues
56+jira tempo                      Opens your JIRA Tempo
57+jira reported [username]        Queries for issues reported by a user
58+jira assigned [username]        Queries for issues assigned to a user
59+jira branch                     Opens an existing issue matching the current branch name
60+EOF
61+}
62+
63 function jira() {
64   emulate -L zsh
65   local action jira_url jira_prefix
66@@ -44,6 +59,8 @@ function jira() {
67     open_command "${jira_url}/secure/CreateIssue!default.jspa"
68   elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
69     _jira_query ${@:-$action}
70+  elif [[ "$action" == "help" || "$action" == "usage" ]]; then
71+    _jira_usage
72   elif [[ "$action" == "mine" ]]; then
73     echo "Opening my issues"
74     open_command "${jira_url}/issues/?filter=-1"