Skip to content

Commit

Permalink
print args at task start/end
Browse files Browse the repository at this point in the history
  • Loading branch information
yemble committed Mar 21, 2017
1 parent 2134664 commit f95af66
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions alfred/alfred.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (a *Alfred) runTask(task string, args []string, formatted bool) bool {
// First, lets show the summary
if copyOfTask.Summary != "" {
fmt.Println("")
say(task, copyOfTask.Summary)
say(task, fmt.Sprintf("%s (Args: %v)", copyOfTask.Summary, copyOfTask.Args))
}

// Register task output
Expand Down Expand Up @@ -255,7 +255,7 @@ func (a *Alfred) runTask(task string, args []string, formatted bool) bool {
if !taskok {
red := color.New(color.FgRed).SprintFunc()
fmt.Println("\n---")
fmt.Println(red("✘"), task)
fmt.Println(red("✘"), fmt.Sprintf("%s FAILED", taskWithArgs(task, copyOfTask.Args)))

// Failed? Lets run the failed tasks
for _, taskDefinition := range copyOfTask.TaskGroup(copyOfTask.Fail, args) {
Expand All @@ -266,7 +266,7 @@ func (a *Alfred) runTask(task string, args []string, formatted bool) bool {
} else {
green := color.New(color.FgGreen).SprintFunc()
fmt.Println("\n---")
fmt.Println(green("✔"), task)
fmt.Println(green("✔"), fmt.Sprintf("%s DONE", taskWithArgs(task, copyOfTask.Args)))
}

// Handle skips ...
Expand Down Expand Up @@ -324,6 +324,14 @@ func (a *Alfred) runTask(task string, args []string, formatted bool) bool {
return true
}

func taskWithArgs(task string, args []string) string {
if len(args) < 1 {
return task
} else {
return fmt.Sprintf("%s (%s)", task, strings.Join(args, ", "))
}
}

// Ensure that the task exists
func (a *Alfred) isValidTask(task string) bool {
if _, exists := a.Tasks[task]; exists {
Expand Down

0 comments on commit f95af66

Please sign in to comment.