From 941824d7f8c4f84b61ca92c4ed468b8a5290dd50 Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Sat, 9 Sep 2017 17:40:26 -0700 Subject: [PATCH] add '{{jira}}' template macro to refer to path of currently running jira command --- jiracli/templates.go | 3 +++ t/.jira.d/config.yml | 22 ++++++++++++++++++++-- t/120custom-commands.t | 31 +++++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/jiracli/templates.go b/jiracli/templates.go index 8a758ae1..7e829598 100644 --- a/jiracli/templates.go +++ b/jiracli/templates.go @@ -60,6 +60,9 @@ func tmpTemplate(templateName string, data interface{}) (string, error) { func TemplateProcessor() *template.Template { funcs := map[string]interface{}{ + "jira": func() string { + return os.Args[0] + }, "toJson": func(content interface{}) (string, error) { bytes, err := json.MarshalIndent(content, "", " ") if err != nil { diff --git a/t/.jira.d/config.yml b/t/.jira.d/config.yml index 0a229ab8..c9363c63 100644 --- a/t/.jira.d/config.yml +++ b/t/.jira.d/config.yml @@ -14,13 +14,31 @@ custom-commands: - name: print-project help: print the name of the configured 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 help: display issues assigned to me script: |- if [ -n "$JIRA_PROJECT" ]; then # 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 # 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 + - 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 diff --git a/t/120custom-commands.t b/t/120custom-commands.t index 5c83655e..d6177fcd 100755 --- a/t/120custom-commands.t +++ b/t/120custom-commands.t @@ -4,7 +4,7 @@ cd $(dirname $0) jira="../jira" . env.sh -PLAN 10 +PLAN 16 # reset login RUNS $jira logout @@ -32,6 +32,15 @@ DIFF <