From 18c17d7acc8f9e2db9a5ac465d2e2e8f401d0704 Mon Sep 17 00:00:00 2001 From: kc merrill Date: Fri, 24 Mar 2017 00:08:18 -0600 Subject: [PATCH] Added templates to task groups --- alfred/task.go | 12 ++++++++++-- examples/demo-everything/.alfred/part-two.alfred.yml | 10 +++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/alfred/task.go b/alfred/task.go index 4b019e7..792389c 100644 --- a/alfred/task.go +++ b/alfred/task.go @@ -107,8 +107,16 @@ func (t *Task) Aliases() []string { } //TaskGroup takes in a string(bleh(1234) whatever(bleh, woot)) and returns the values and args -func (t *Task) TaskGroup(tasks string, args []string) []TaskDefinition { - tasks = strings.TrimSpace(tasks) +func (t *Task) TaskGroup(rawTasks string, args []string) []TaskDefinition { + + // Prepare it + ok, tasks := t.template(strings.TrimSpace(rawTasks)) + if !ok { + say("error", "Missing argument(s).") + // No need in going on, programmer error + os.Exit(1) + } + results := make([]TaskDefinition, 0) if tasks == "" { // If there is nothing, then there is nothing to report diff --git a/examples/demo-everything/.alfred/part-two.alfred.yml b/examples/demo-everything/.alfred/part-two.alfred.yml index 6b62c74..342d401 100644 --- a/examples/demo-everything/.alfred/part-two.alfred.yml +++ b/examples/demo-everything/.alfred/part-two.alfred.yml @@ -16,4 +16,12 @@ fourty.two: setup: fourty.one summary: Retrieve a registered variable command: | - echo The variable is {{ index .Vars "my.new.var"}} \ No newline at end of file + echo The variable is {{ index .Vars "my.new.var"}} + +fourty.three: + summary: Lets call a task with params + tasks: fourty.four(a, {{ index .Args 0 }}) fourty.four(b, {{ index .Args 0}}) + +fourty.four: + summary: A task with two params + command: echo {{ index .Args 0 }} {{ index .Args 1 }} \ No newline at end of file