mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-07 21:43:32 +02:00
add '{{jira}}' template macro to refer to path of currently running jira command
This commit is contained in:
@@ -60,6 +60,9 @@ func tmpTemplate(templateName string, data interface{}) (string, error) {
|
|||||||
|
|
||||||
func TemplateProcessor() *template.Template {
|
func TemplateProcessor() *template.Template {
|
||||||
funcs := map[string]interface{}{
|
funcs := map[string]interface{}{
|
||||||
|
"jira": func() string {
|
||||||
|
return os.Args[0]
|
||||||
|
},
|
||||||
"toJson": func(content interface{}) (string, error) {
|
"toJson": func(content interface{}) (string, error) {
|
||||||
bytes, err := json.MarshalIndent(content, "", " ")
|
bytes, err := json.MarshalIndent(content, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+20
-2
@@ -14,13 +14,31 @@ custom-commands:
|
|||||||
- name: print-project
|
- name: print-project
|
||||||
help: print the name of the configured project
|
help: print the name of the configured project
|
||||||
script: "echo $JIRA_PROJECT"
|
script: "echo $JIRA_PROJECT"
|
||||||
|
- name: jira-path
|
||||||
|
help: print the path the jira command that is running this alias
|
||||||
|
script: |-
|
||||||
|
echo {{jira}}
|
||||||
- name: mine
|
- name: mine
|
||||||
help: display issues assigned to me
|
help: display issues assigned to me
|
||||||
script: |-
|
script: |-
|
||||||
if [ -n "$JIRA_PROJECT" ]; then
|
if [ -n "$JIRA_PROJECT" ]; then
|
||||||
# if `project: ...` configured just list the issues for current project
|
# if `project: ...` configured just list the issues for current project
|
||||||
jira list --template table --query "resolution = unresolved and assignee=currentuser() and project = $JIRA_PROJECT ORDER BY priority asc, created"
|
{{jira}} list --template table --query "resolution = unresolved and assignee=currentuser() and project = $JIRA_PROJECT ORDER BY priority asc, created"
|
||||||
else
|
else
|
||||||
# otherwise list issues for all project
|
# otherwise list issues for all project
|
||||||
jira list --template table --query "resolution = unresolved and assignee=currentuser() ORDER BY priority asc, created"
|
{{jira}} list --template table --query "resolution = unresolved and assignee=currentuser() ORDER BY priority asc, created"
|
||||||
fi
|
fi
|
||||||
|
- name: argtest
|
||||||
|
help: testing passing args
|
||||||
|
script: |-
|
||||||
|
echo {{args.ARG}}
|
||||||
|
args:
|
||||||
|
- name: ARG
|
||||||
|
help: string to echo for testing
|
||||||
|
- name: opttest
|
||||||
|
help: testing passing option flags
|
||||||
|
script: |-
|
||||||
|
echo {{options.OPT}}
|
||||||
|
options:
|
||||||
|
- name: OPT
|
||||||
|
help: string to echo for testing
|
||||||
|
|||||||
+29
-2
@@ -4,7 +4,7 @@ cd $(dirname $0)
|
|||||||
jira="../jira"
|
jira="../jira"
|
||||||
. env.sh
|
. env.sh
|
||||||
|
|
||||||
PLAN 10
|
PLAN 16
|
||||||
|
|
||||||
# reset login
|
# reset login
|
||||||
RUNS $jira logout
|
RUNS $jira logout
|
||||||
@@ -32,6 +32,15 @@ DIFF <<EOF
|
|||||||
BASIC
|
BASIC
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
## Testing the example custom commands, jira-path
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
RUNS $jira jira-path
|
||||||
|
DIFF <<EOF
|
||||||
|
../jira
|
||||||
|
EOF
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
## Testing the example custom commands, env
|
## Testing the example custom commands, env
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@@ -39,7 +48,7 @@ EOF
|
|||||||
RUNS $jira env
|
RUNS $jira env
|
||||||
DIFF <<'EOF'
|
DIFF <<'EOF'
|
||||||
JIRACLOUD=1
|
JIRACLOUD=1
|
||||||
JIRA_CUSTOM_COMMANDS=[{"name":"env","script":"env | sort | grep JIRA","help":"print the JIRA environment variables available to custom commands"},{"name":"print-project","script":"echo $JIRA_PROJECT","help":"print the name of the configured project"},{"name":"mine","script":"if [ -n \"$JIRA_PROJECT\" ]; then\n # if `project: ...` configured just list the issues for current project\n jira list --template table --query \"resolution = unresolved and assignee=currentuser() and project = $JIRA_PROJECT ORDER BY priority asc, created\"\nelse\n # otherwise list issues for all project\n jira list --template table --query \"resolution = unresolved and assignee=currentuser() ORDER BY priority asc, created\"\nfi","help":"display issues assigned to me"}]
|
JIRA_CUSTOM_COMMANDS=[{"name":"env","script":"env | sort | grep JIRA","help":"print the JIRA environment variables available to custom commands"},{"name":"print-project","script":"echo $JIRA_PROJECT","help":"print the name of the configured project"},{"name":"jira-path","script":"echo {{jira}}","help":"print the path the jira command that is running this alias"},{"name":"mine","script":"if [ -n \"$JIRA_PROJECT\" ]; then\n # if `project: ...` configured just list the issues for current project\n {{jira}} list --template table --query \"resolution = unresolved and assignee=currentuser() and project = $JIRA_PROJECT ORDER BY priority asc, created\"\nelse\n # otherwise list issues for all project\n {{jira}} list --template table --query \"resolution = unresolved and assignee=currentuser() ORDER BY priority asc, created\"\nfi","help":"display issues assigned to me"},{"name":"argtest","args":[{"name":"ARG","help":"string to echo for testing"}],"script":"echo {{args.ARG}}","help":"testing passing args"},{"name":"opttest","options":[{"name":"OPT","help":"string to echo for testing"}],"script":"echo {{options.OPT}}","help":"testing passing option flags"}]
|
||||||
JIRA_ENDPOINT=https://go-jira.atlassian.net
|
JIRA_ENDPOINT=https://go-jira.atlassian.net
|
||||||
JIRA_LOG_FORMAT=%{level:-5s} %{message}
|
JIRA_LOG_FORMAT=%{level:-5s} %{message}
|
||||||
JIRA_PASSWORD_SOURCE=pass
|
JIRA_PASSWORD_SOURCE=pass
|
||||||
@@ -47,6 +56,24 @@ JIRA_PROJECT=BASIC
|
|||||||
JIRA_USER=gojira
|
JIRA_USER=gojira
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
## Testing the example custom commands, argtest
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
RUNS $jira argtest TEST
|
||||||
|
DIFF <<EOF
|
||||||
|
TEST
|
||||||
|
EOF
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
## Testing the example custom commands, opttest
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
RUNS $jira opttest --OPT TEST
|
||||||
|
DIFF <<EOF
|
||||||
|
TEST
|
||||||
|
EOF
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
## Use the "mine" alias to list issues assigned to self
|
## Use the "mine" alias to list issues assigned to self
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user