mirror of
https://github.com/go-task/task.git
synced 2025-02-13 13:59:32 +02:00
display task name on details
This commit is contained in:
parent
c0f9af5daa
commit
31b60f7f60
8
task.go
8
task.go
@ -65,7 +65,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if e.Details {
|
if e.Details {
|
||||||
e.displayTaskDetails(calls[0].Task)
|
e.printTaskDetails(calls[0].Task)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,12 +81,16 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Executor) displayTaskDetails(task string) {
|
func (e *Executor) printTaskDetails(task string) {
|
||||||
s := e.Taskfile.Tasks[task].Details
|
s := e.Taskfile.Tasks[task].Details
|
||||||
if s == "" {
|
if s == "" {
|
||||||
e.Logger.Errf("task: There is no detailed description for task: %s", task)
|
e.Logger.Errf("task: There is no detailed description for task: %s", task)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.Logger.Outf("task: " + task)
|
||||||
|
e.Logger.Outf("")
|
||||||
|
|
||||||
lines := strings.Split(s, "\n")
|
lines := strings.Split(s, "\n")
|
||||||
for i, line := range lines {
|
for i, line := range lines {
|
||||||
notLastLine := i+1 < len(lines)
|
notLastLine := i+1 < len(lines)
|
||||||
|
@ -582,7 +582,7 @@ func TestDetails(t *testing.T) {
|
|||||||
|
|
||||||
buff.Reset()
|
buff.Reset()
|
||||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"}))
|
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(), "task-with-details was executed")
|
||||||
assert.NotContains(t, buff.String(), "dependend-task was executed")
|
assert.NotContains(t, buff.String(), "dependend-task was executed")
|
||||||
@ -601,6 +601,6 @@ func TestDetails(t *testing.T) {
|
|||||||
|
|
||||||
buff.Reset()
|
buff.Reset()
|
||||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-description-containing-empty-line"}))
|
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")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user