Skip to content

Commit

Permalink
Added templates to task groups
Browse files Browse the repository at this point in the history
  • Loading branch information
kcmerrill committed Mar 24, 2017
1 parent baa2db4 commit 18c17d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 10 additions & 2 deletions alfred/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/demo-everything/.alfred/part-two.alfred.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ fourty.two:
setup: fourty.one
summary: Retrieve a registered variable
command: |
echo The variable is {{ index .Vars "my.new.var"}}
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 }}

0 comments on commit 18c17d7

Please sign in to comment.