From f1d83e92a73146666b4aff50f1a7a0fcb87c1c76 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:08:27 +0100 Subject: [PATCH] print command stub on details --- task.go | 12 ++++++++++-- task_test.go | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/task.go b/task.go index be0463b0..f13782b5 100644 --- a/task.go +++ b/task.go @@ -91,11 +91,19 @@ func (e *Executor) printTaskDetails(task string) { e.Logger.Outf("task: " + task) e.Logger.Outf("") - lines := strings.Split(s, "\n") + Logger := e.Logger + displayTaskDetailedDescription(s, Logger) + + e.Logger.Outf("") + e.Logger.Outf("Commands:") +} + +func displayTaskDetailedDescription(description string, Logger *logger.Logger) { + lines := strings.Split(description, "\n") for i, line := range lines { notLastLine := i+1 < len(lines) if notLastLine || line != "" { - e.Logger.Outf(line) + Logger.Outf(line) } } } diff --git a/task_test.go b/task_test.go index 1dac2b69..d8745868 100644 --- a/task_test.go +++ b/task_test.go @@ -582,7 +582,7 @@ func TestDetails(t *testing.T) { buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) - assert.Equal(t, buff.String(), "task: task-with-details\n\ndetails of task-with-details - line 1\n"+"line 2\n"+"line 3\n") + assert.Equal(t, buff.String(), "task: task-with-details\n\ndetails of task-with-details - line 1\n"+"line 2\n"+"line 3\n\nCommands:\n") assert.NotContains(t, buff.String(), "task-with-details was executed") assert.NotContains(t, buff.String(), "dependend-task was executed") @@ -601,6 +601,6 @@ func TestDetails(t *testing.T) { buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-description-containing-empty-line"})) - assert.Equal(t, buff.String(), "task: task-with-description-containing-empty-line\n\nFirst line followed by empty line\n\nLast Line\n") + assert.Equal(t, buff.String(), "task: task-with-description-containing-empty-line\n\nFirst line followed by empty line\n\nLast Line\n\nCommands:\n") }