1
0
mirror of https://github.com/go-task/task.git synced 2025-01-26 05:27:15 +02:00

print command stub on details

This commit is contained in:
jaedle 2019-02-24 14:08:27 +01:00
parent 31b60f7f60
commit f1d83e92a7
2 changed files with 12 additions and 4 deletions

12
task.go
View File

@ -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)
}
}
}

View File

@ -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")
}