diff --git a/task.go b/task.go index 1e2612a1..be0463b0 100644 --- a/task.go +++ b/task.go @@ -65,7 +65,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } if e.Details { - e.displayTaskDetails(calls[0].Task) + e.printTaskDetails(calls[0].Task) return nil } @@ -81,12 +81,16 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { return nil } -func (e *Executor) displayTaskDetails(task string) { +func (e *Executor) printTaskDetails(task string) { s := e.Taskfile.Tasks[task].Details if s == "" { e.Logger.Errf("task: There is no detailed description for task: %s", task) return } + + e.Logger.Outf("task: " + task) + e.Logger.Outf("") + lines := strings.Split(s, "\n") for i, line := range lines { notLastLine := i+1 < len(lines) diff --git a/task_test.go b/task_test.go index c3680d1a..1dac2b69 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(), "details 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") 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(), "First 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") }