From 4fa983bde71af8d6d3617c3e4ef6388b68384830 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 08:24:09 +0100 Subject: [PATCH 01/83] ignore ide configuration --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 246c2621..d5340eb2 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ dist/ .DS_Store + +# intellij idea/goland +.idea/ From 13614fb3c4b2a4a8019b40c9d6fd1e771a270fb2 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 08:51:20 +0100 Subject: [PATCH 02/83] add details flag for cli --- cmd/task/task.go | 5 ++++- task.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/task/task.go b/cmd/task/task.go index 694a0a5c..4140c5d7 100644 --- a/cmd/task/task.go +++ b/cmd/task/task.go @@ -17,7 +17,7 @@ var ( version = "master" ) -const usage = `Usage: task [-ilfwvsd] [--init] [--list] [--force] [--watch] [--verbose] [--silent] [--dir] [--dry] [task...] +const usage = `Usage: task [-ilfwvsd] [--init] [--list] [--force] [--watch] [--verbose] [--silent] [--dir] [--dry] [--details] [task...] Runs the specified task(s). Falls back to the "default" task if no task name was specified, or lists all tasks if an unknown task name was specified. @@ -56,6 +56,7 @@ func main() { verbose bool silent bool dry bool + details bool dir string output string ) @@ -69,6 +70,7 @@ func main() { pflag.BoolVarP(&verbose, "verbose", "v", false, "enables verbose mode") pflag.BoolVarP(&silent, "silent", "s", false, "disables echoing") pflag.BoolVar(&dry, "dry", false, "compiles and prints tasks in the order that they would be run, without executing them") + pflag.BoolVar(&details, "details", false, "show detailed description about a task if present") pflag.StringVarP(&dir, "dir", "d", "", "sets directory of execution") pflag.StringVarP(&output, "output", "o", "", "sets output style: [interleaved|group|prefixed]") pflag.Parse() @@ -96,6 +98,7 @@ func main() { Silent: silent, Dir: dir, Dry: dry, + Details: details, Stdin: os.Stdin, Stdout: os.Stdout, diff --git a/task.go b/task.go index 1632d6d6..8b222c84 100644 --- a/task.go +++ b/task.go @@ -36,6 +36,7 @@ type Executor struct { Verbose bool Silent bool Dry bool + Details bool Stdin io.Reader Stdout io.Writer From 07221a1b209bc9405799d06119315bddf066a014 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 09:24:57 +0100 Subject: [PATCH 03/83] output detailed task description --- Taskfile.yml | 4 ++++ internal/taskfile/task.go | 3 ++- task.go | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index c85fd0ff..a92ac381 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -17,6 +17,10 @@ tasks: install: desc: Installs Task + details: | + Push Docker image to Google cloud registry. + + The env variable "DOCKER_IMAGE_FQN" define the Docker image name to push. cmds: - go install -v -ldflags="-w -s -X main.version={{.GIT_COMMIT}}" ./cmd/task env: diff --git a/internal/taskfile/task.go b/internal/taskfile/task.go index 4ebfd5e5..0bd63b26 100644 --- a/internal/taskfile/task.go +++ b/internal/taskfile/task.go @@ -1,6 +1,6 @@ package taskfile -// Tasks representas a group of tasks +// Tasks represents a group of tasks type Tasks map[string]*Task // Task represents a task @@ -9,6 +9,7 @@ type Task struct { Cmds []*Cmd Deps []*Dep Desc string + Details string Sources []string Generates []string Status []string diff --git a/task.go b/task.go index 8b222c84..11bac147 100644 --- a/task.go +++ b/task.go @@ -63,6 +63,18 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } } + if e.Details { + task := calls[0].Task + + if e.Taskfile.Tasks[task].Details == "" { + e.Logger.Errf("task: There is no detailed description for task: %s", task) + return nil + } + + e.Logger.Outf(e.Taskfile.Tasks[task].Details) + return nil + } + if e.Watch { return e.watchTasks(calls...) } From 4b7f058f4117f4cb5d0479f3ed0995ed4325d055 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 09:25:39 +0100 Subject: [PATCH 04/83] refacotring --- task.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/task.go b/task.go index 11bac147..9c90cebc 100644 --- a/task.go +++ b/task.go @@ -68,10 +68,9 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { if e.Taskfile.Tasks[task].Details == "" { e.Logger.Errf("task: There is no detailed description for task: %s", task) - return nil + } else { + e.Logger.Outf(e.Taskfile.Tasks[task].Details) } - - e.Logger.Outf(e.Taskfile.Tasks[task].Details) return nil } From c73ddc35525832e1ec5cfc01d913f85ca4308ccd Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 09:27:26 +0100 Subject: [PATCH 05/83] refactoring --- task.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/task.go b/task.go index 9c90cebc..e0406c5a 100644 --- a/task.go +++ b/task.go @@ -64,13 +64,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } if e.Details { - task := calls[0].Task - - if e.Taskfile.Tasks[task].Details == "" { - e.Logger.Errf("task: There is no detailed description for task: %s", task) - } else { - e.Logger.Outf(e.Taskfile.Tasks[task].Details) - } + displayTaskDetails(e, calls[0].Task) return nil } @@ -86,6 +80,14 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { return nil } +func displayTaskDetails(e *Executor, task string) { + if e.Taskfile.Tasks[task].Details == "" { + e.Logger.Errf("task: There is no detailed description for task: %s", task) + } else { + e.Logger.Outf(e.Taskfile.Tasks[task].Details) + } +} + // Setup setups Executor's internal state func (e *Executor) Setup() error { var err error From 9be7521b83e8b165d4813b1772f3406bb30f0811 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 09:28:25 +0100 Subject: [PATCH 06/83] refactoring --- task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.go b/task.go index e0406c5a..4d6f9453 100644 --- a/task.go +++ b/task.go @@ -64,7 +64,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } if e.Details { - displayTaskDetails(e, calls[0].Task) + e.displayTaskDetails(calls[0].Task) return nil } @@ -80,7 +80,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { return nil } -func displayTaskDetails(e *Executor, task string) { +func (e *Executor) displayTaskDetails(task string) { if e.Taskfile.Tasks[task].Details == "" { e.Logger.Errf("task: There is no detailed description for task: %s", task) } else { From 5c823d51d0ab49ed6b7f582db5232fd70cb5f602 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 09:29:19 +0100 Subject: [PATCH 07/83] revert changes for taskfile --- Taskfile.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index a92ac381..c85fd0ff 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -17,10 +17,6 @@ tasks: install: desc: Installs Task - details: | - Push Docker image to Google cloud registry. - - The env variable "DOCKER_IMAGE_FQN" define the Docker image name to push. cmds: - go install -v -ldflags="-w -s -X main.version={{.GIT_COMMIT}}" ./cmd/task env: From f9adeba7f1f1ed69134cf70cf0bc3ddf87267812 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 09:53:49 +0100 Subject: [PATCH 08/83] add basic test for details --- task_test.go | 15 +++++++++++++++ testdata/details/Taskfile.yml | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 testdata/details/Taskfile.yml diff --git a/task_test.go b/task_test.go index 4b3b338f..707f0223 100644 --- a/task_test.go +++ b/task_test.go @@ -553,3 +553,18 @@ func TestIncludesCallingRoot(t *testing.T) { } tt.Run(t) } + +func TestDetails(t *testing.T) { + const dir = "testdata/details" + + var buff bytes.Buffer + e := task.Executor{ + Dir: dir, + Stdout: &buff, + Stderr: &buff, + Details: true, + } + assert.NoError(t, e.Setup()) + assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, "This is a very long detailed description\nwith multiple lines\n") + assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Details, "") +} diff --git a/testdata/details/Taskfile.yml b/testdata/details/Taskfile.yml new file mode 100644 index 00000000..e8bcb9d3 --- /dev/null +++ b/testdata/details/Taskfile.yml @@ -0,0 +1,12 @@ +version: 2 +tasks: + task-with-details: + details: | + This is a very long detailed description + with multiple lines + cmds: + - exit 0 + + task-without-details: + cmds: + - exit 0 From a951f2403d11df8ea77b4173c4582b88d13037e4 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:01:48 +0100 Subject: [PATCH 09/83] add more tests for details --- task_test.go | 16 +++++++++++++++- testdata/details/Taskfile.yml | 15 +++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/task_test.go b/task_test.go index 707f0223..ec5af38b 100644 --- a/task_test.go +++ b/task_test.go @@ -563,8 +563,22 @@ func TestDetails(t *testing.T) { Stdout: &buff, Stderr: &buff, Details: true, + Silent: true, } assert.NoError(t, e.Setup()) - assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, "This is a very long detailed description\nwith multiple lines\n") + const longDetails = "This is a very long detailed description\nwith multiple lines\n" + assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, longDetails) + const shortDetails = "short details" + assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Details, shortDetails) assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Details, "") + + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) + assert.NotContains(t, buff.String(), "task-with-details was executed") + assert.NotContains(t, buff.String(), "dependend-task was executed") + assert.Contains(t, buff.String(), longDetails) + + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-without-details"})) + assert.NotContains(t, buff.String(), "task-without-details was executed") + assert.NotContains(t, buff.String(), "dependend-task was executed") + } diff --git a/testdata/details/Taskfile.yml b/testdata/details/Taskfile.yml index e8bcb9d3..c62300f0 100644 --- a/testdata/details/Taskfile.yml +++ b/testdata/details/Taskfile.yml @@ -1,12 +1,23 @@ version: 2 tasks: task-with-details: + deps: [dependend-task] details: | This is a very long detailed description with multiple lines cmds: - - exit 0 + - echo 'task-with-details was executed' task-without-details: + deps: [dependend-task] cmds: - - exit 0 + - echo 'task-without-details was executed' + + dependend-task: + cmds: + - echo 'dependend-task was executed' + + other-task-with-details: + details: short details + cmds: + - echo 'other-task-with-details was executed' From 4b64fcb8a48f9f8ba78ff89f356be3f9e65e9e9e Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:09:55 +0100 Subject: [PATCH 10/83] add more tests --- task_test.go | 28 ++++++++++++++++++++++------ testdata/details/Taskfile.yml | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/task_test.go b/task_test.go index ec5af38b..b8e8747b 100644 --- a/task_test.go +++ b/task_test.go @@ -554,6 +554,19 @@ func TestIncludesCallingRoot(t *testing.T) { tt.Run(t) } +func TestDetailsParsing(t *testing.T) { + const dir = "testdata/details" + + e := task.Executor{ + Dir: dir, + } + assert.NoError(t, e.Setup()) + + assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, "This is a very long detailed description\nwith multiple lines\n") + assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Details, "short details") + assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Details, "") +} + func TestDetails(t *testing.T) { const dir = "testdata/details" @@ -566,19 +579,22 @@ func TestDetails(t *testing.T) { Silent: true, } assert.NoError(t, e.Setup()) - const longDetails = "This is a very long detailed description\nwith multiple lines\n" - assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, longDetails) - const shortDetails = "short details" - assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Details, shortDetails) - assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Details, "") + buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) + assert.Contains(t, buff.String(), "This is a very long detailed description") + assert.Contains(t, buff.String(), "with multiple lines") + assert.NotContains(t, buff.String(), "task-with-details was executed") assert.NotContains(t, buff.String(), "dependend-task was executed") - assert.Contains(t, buff.String(), longDetails) + buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-without-details"})) assert.NotContains(t, buff.String(), "task-without-details was executed") assert.NotContains(t, buff.String(), "dependend-task was executed") + buff.Reset() + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "other-task-with-details"}, taskfile.Call{Task: "task-with-details"})) + assert.Contains(t, buff.String(), "details of other-task-with-details") + assert.NotContains(t, buff.String(), "This is a very long detailed description") } diff --git a/testdata/details/Taskfile.yml b/testdata/details/Taskfile.yml index c62300f0..ad84b4fb 100644 --- a/testdata/details/Taskfile.yml +++ b/testdata/details/Taskfile.yml @@ -18,6 +18,6 @@ tasks: - echo 'dependend-task was executed' other-task-with-details: - details: short details + details: details of other-task-with-details cmds: - echo 'other-task-with-details was executed' From 31ead854c7419d71db36ac1afd730fd6c7fe44dc Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:19:08 +0100 Subject: [PATCH 11/83] fix test expectation --- task_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task_test.go b/task_test.go index b8e8747b..39b20b7d 100644 --- a/task_test.go +++ b/task_test.go @@ -563,7 +563,7 @@ func TestDetailsParsing(t *testing.T) { assert.NoError(t, e.Setup()) assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, "This is a very long detailed description\nwith multiple lines\n") - assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Details, "short details") + assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Details, "details of other-task-with-details") assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Details, "") } From 80d88d97893d01e32e6247735630300fcce2b5b4 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:22:14 +0100 Subject: [PATCH 12/83] refactoring --- task_test.go | 9 +++++---- testdata/details/Taskfile.yml | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/task_test.go b/task_test.go index 39b20b7d..0db17941 100644 --- a/task_test.go +++ b/task_test.go @@ -562,7 +562,7 @@ func TestDetailsParsing(t *testing.T) { } assert.NoError(t, e.Setup()) - assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, "This is a very long detailed description\nwith multiple lines\n") + assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, "details of task-with-details - line 1\nline 2\nline 3\n") assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Details, "details of other-task-with-details") assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Details, "") } @@ -582,8 +582,9 @@ func TestDetails(t *testing.T) { buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) - assert.Contains(t, buff.String(), "This is a very long detailed description") - assert.Contains(t, buff.String(), "with multiple lines") + assert.Contains(t, buff.String(), "details of task-with-details - line 1") + assert.Contains(t, buff.String(), "line 2") + assert.Contains(t, buff.String(), "line 3") assert.NotContains(t, buff.String(), "task-with-details was executed") assert.NotContains(t, buff.String(), "dependend-task was executed") @@ -596,5 +597,5 @@ func TestDetails(t *testing.T) { buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "other-task-with-details"}, taskfile.Call{Task: "task-with-details"})) assert.Contains(t, buff.String(), "details of other-task-with-details") - assert.NotContains(t, buff.String(), "This is a very long detailed description") + assert.NotContains(t, buff.String(), "details of task-with-details") } diff --git a/testdata/details/Taskfile.yml b/testdata/details/Taskfile.yml index ad84b4fb..efb09efa 100644 --- a/testdata/details/Taskfile.yml +++ b/testdata/details/Taskfile.yml @@ -3,8 +3,9 @@ tasks: task-with-details: deps: [dependend-task] details: | - This is a very long detailed description - with multiple lines + details of task-with-details - line 1 + line 2 + line 3 cmds: - echo 'task-with-details was executed' From 5a23250d32fe35215fe3f42497150a12fe0cf80e Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:25:26 +0100 Subject: [PATCH 13/83] simplified tests --- task_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/task_test.go b/task_test.go index 0db17941..fed7f824 100644 --- a/task_test.go +++ b/task_test.go @@ -591,8 +591,7 @@ func TestDetails(t *testing.T) { buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-without-details"})) - assert.NotContains(t, buff.String(), "task-without-details was executed") - assert.NotContains(t, buff.String(), "dependend-task was executed") + assert.Equal(t, buff.String(), "task: There is no detailed description for task: task-without-details\n") buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "other-task-with-details"}, taskfile.Call{Task: "task-with-details"})) From 0164bc21ea093b9ec85990be8aa0e9a4d789bd2b Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:28:15 +0100 Subject: [PATCH 14/83] be more specific in tests about output --- task.go | 1 + task_test.go | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/task.go b/task.go index 4d6f9453..49fa1049 100644 --- a/task.go +++ b/task.go @@ -84,6 +84,7 @@ func (e *Executor) displayTaskDetails(task string) { if e.Taskfile.Tasks[task].Details == "" { e.Logger.Errf("task: There is no detailed description for task: %s", task) } else { + e.Logger.Outf(e.Taskfile.Tasks[task].Details) } } diff --git a/task_test.go b/task_test.go index fed7f824..6c7c18f0 100644 --- a/task_test.go +++ b/task_test.go @@ -582,9 +582,7 @@ func TestDetails(t *testing.T) { buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) - assert.Contains(t, buff.String(), "details of task-with-details - line 1") - assert.Contains(t, buff.String(), "line 2") - assert.Contains(t, buff.String(), "line 3") + assert.Equal(t, buff.String(), "details of task-with-details - line 1\n"+"line 2\n"+"line 3\n\n") assert.NotContains(t, buff.String(), "task-with-details was executed") assert.NotContains(t, buff.String(), "dependend-task was executed") From b97221cdb223f980549725e76bb703b9753f244e Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:31:25 +0100 Subject: [PATCH 15/83] ignore empty lines on description --- task.go | 14 ++++++++++---- task_test.go | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/task.go b/task.go index 49fa1049..9e4123b4 100644 --- a/task.go +++ b/task.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "strings" "sync/atomic" "github.com/go-task/task/v2/internal/compiler" @@ -81,11 +82,16 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } func (e *Executor) displayTaskDetails(task string) { - if e.Taskfile.Tasks[task].Details == "" { + s := e.Taskfile.Tasks[task].Details + if s == "" { e.Logger.Errf("task: There is no detailed description for task: %s", task) - } else { - - e.Logger.Outf(e.Taskfile.Tasks[task].Details) + return + } + lines := strings.Split(s, "\n") + for _, line := range lines { + if line != "" { + e.Logger.Outf(line) + } } } diff --git a/task_test.go b/task_test.go index 6c7c18f0..aedece21 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\n") + assert.Equal(t, buff.String(), "details 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") From 399a2b38f3f5df36108837193affeedfc3d945e0 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:52:31 +0100 Subject: [PATCH 16/83] add documentation for details --- docs/usage.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index 29f55ed2..55c2cf8f 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -542,6 +542,34 @@ would print the following output: * test: Run all the go tests. ``` +## Detailed task description + +Running `task --details task-name` will show a detailed description of a task if present. +The following Taskfile: + +```yaml +version: '2' + +tasks: + release: + details: | + Release your project to github + + Please make sure that you have set GITHUB_TOKEN before starting. + cmds: + - your-release-tool +``` + +with running ``task --details release`` would print the following output: + +``` +Release your project to github + +Please make sure that you have set GITHUB_TOKEN before starting +``` + +*showing the detailed description will not execute the command* + ## Silent mode Silent mode disables echoing of commands before Task runs it. From 1ac6f17e6ae68a37b5b83dd0909dab9b5b188959 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:58:44 +0100 Subject: [PATCH 17/83] should not surpress empty lines expect on last line --- task.go | 5 +++-- task_test.go | 5 +++++ testdata/details/Taskfile.yml | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/task.go b/task.go index 9e4123b4..1e2612a1 100644 --- a/task.go +++ b/task.go @@ -88,8 +88,9 @@ func (e *Executor) displayTaskDetails(task string) { return } lines := strings.Split(s, "\n") - for _, line := range lines { - if line != "" { + for i, line := range lines { + notLastLine := i+1 < len(lines) + if notLastLine || line != "" { e.Logger.Outf(line) } } diff --git a/task_test.go b/task_test.go index aedece21..8baeba46 100644 --- a/task_test.go +++ b/task_test.go @@ -595,4 +595,9 @@ func TestDetails(t *testing.T) { assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "other-task-with-details"}, taskfile.Call{Task: "task-with-details"})) assert.Contains(t, buff.String(), "details of other-task-with-details") assert.NotContains(t, buff.String(), "details of task-with-details") + + 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") + } diff --git a/testdata/details/Taskfile.yml b/testdata/details/Taskfile.yml index efb09efa..d2b1ec49 100644 --- a/testdata/details/Taskfile.yml +++ b/testdata/details/Taskfile.yml @@ -22,3 +22,11 @@ tasks: details: details of other-task-with-details cmds: - echo 'other-task-with-details was executed' + + task-with-description-containing-empty-line: + details: | + First line followed by empty line + + Last Line + cmds: + - exit 0 From 3c0cf3cd555239207fc7f96f1f7deea8a6438875 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 12:00:45 +0100 Subject: [PATCH 18/83] fix documentation --- docs/usage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 55c2cf8f..4f6d8aa0 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -565,10 +565,10 @@ with running ``task --details release`` would print the following output: ``` Release your project to github -Please make sure that you have set GITHUB_TOKEN before starting +Please make sure that you have set GITHUB_TOKEN before starting. ``` -*showing the detailed description will not execute the command* +Please note: *showing the detailed description will not execute the command* ## Silent mode From b25a9e8884d06fe190d78200ceb634398ddf4902 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 12:13:18 +0100 Subject: [PATCH 19/83] refactoring --- task_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/task_test.go b/task_test.go index 8baeba46..f91deb9c 100644 --- a/task_test.go +++ b/task_test.go @@ -592,9 +592,11 @@ func TestDetails(t *testing.T) { assert.Equal(t, buff.String(), "task: There is no detailed description for task: task-without-details\n") buff.Reset() - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "other-task-with-details"}, taskfile.Call{Task: "task-with-details"})) - assert.Contains(t, buff.String(), "details of other-task-with-details") - assert.NotContains(t, buff.String(), "details of task-with-details") + const firstTask = "other-task-with-details" + const secondTask = "task-with-details" + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: firstTask}, taskfile.Call{Task: secondTask})) + assert.Contains(t, buff.String(), "details of "+firstTask) + assert.NotContains(t, buff.String(), "details of "+secondTask) buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-description-containing-empty-line"})) From c0f9af5daab1ef501e70ad6c59c928a2ff48d4e7 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 12:15:59 +0100 Subject: [PATCH 20/83] refactoring --- task_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/task_test.go b/task_test.go index f91deb9c..c3680d1a 100644 --- a/task_test.go +++ b/task_test.go @@ -588,8 +588,9 @@ func TestDetails(t *testing.T) { assert.NotContains(t, buff.String(), "dependend-task was executed") buff.Reset() - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-without-details"})) - assert.Equal(t, buff.String(), "task: There is no detailed description for task: task-without-details\n") + const noDetails = "task-without-details" + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: noDetails})) + assert.Equal(t, buff.String(), "task: There is no detailed description for task: "+noDetails+"\n") buff.Reset() const firstTask = "other-task-with-details" From 31b60f7f600ebc680a2e3086355332f2b751ce72 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:01:53 +0100 Subject: [PATCH 21/83] display task name on details --- task.go | 8 ++++++-- task_test.go | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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") } From f1d83e92a73146666b4aff50f1a7a0fcb87c1c76 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:08:27 +0100 Subject: [PATCH 22/83] 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") } From 0a808b1212f525f3ac66cd928056299a83967303 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:10:46 +0100 Subject: [PATCH 23/83] fix swapped expected and actual parameter --- task_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/task_test.go b/task_test.go index d8745868..2c374a2d 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\nCommands:\n") + assert.Equal(t, "task: task-with-details\n\ndetails of task-with-details - line 1\n"+"line 2\n"+"line 3\n\nCommands:\n", buff.String()) assert.NotContains(t, buff.String(), "task-with-details was executed") assert.NotContains(t, buff.String(), "dependend-task was executed") @@ -590,7 +590,7 @@ func TestDetails(t *testing.T) { buff.Reset() const noDetails = "task-without-details" assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: noDetails})) - assert.Equal(t, buff.String(), "task: There is no detailed description for task: "+noDetails+"\n") + assert.Equal(t, "task: There is no detailed description for task: "+noDetails+"\n", buff.String()) buff.Reset() const firstTask = "other-task-with-details" @@ -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\nCommands:\n") + assert.Equal(t, "task: task-with-description-containing-empty-line\n\nFirst line followed by empty line\n\nLast Line\n\nCommands:\n", buff.String()) } From b05fa0821d4d7aa76c7880e95eb7868d4ce70a63 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:18:07 +0100 Subject: [PATCH 24/83] move expectations for output to testdata --- task.go | 2 +- task_test.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/task.go b/task.go index f13782b5..dd0dce24 100644 --- a/task.go +++ b/task.go @@ -95,7 +95,7 @@ func (e *Executor) printTaskDetails(task string) { displayTaskDetailedDescription(s, Logger) e.Logger.Outf("") - e.Logger.Outf("Commands:") + e.Logger.Outf("commands:") } func displayTaskDetailedDescription(description string, Logger *logger.Logger) { diff --git a/task_test.go b/task_test.go index 2c374a2d..e9866607 100644 --- a/task_test.go +++ b/task_test.go @@ -580,9 +580,11 @@ func TestDetails(t *testing.T) { } assert.NoError(t, e.Setup()) - buff.Reset() + exp, err := ioutil.ReadFile(dir + "/expected-task-with-details-details.txt") + assert.NoError(t, err, "error reading text fixture") + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) - assert.Equal(t, "task: task-with-details\n\ndetails of task-with-details - line 1\n"+"line 2\n"+"line 3\n\nCommands:\n", buff.String()) + assert.Equal(t, string(exp), buff.String()) assert.NotContains(t, buff.String(), "task-with-details was executed") assert.NotContains(t, buff.String(), "dependend-task was executed") @@ -601,6 +603,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, "task: task-with-description-containing-empty-line\n\nFirst line followed by empty line\n\nLast Line\n\nCommands:\n", buff.String()) + assert.Equal(t, "task: task-with-description-containing-empty-line\n\nFirst line followed by empty line\n\nLast Line\n\ncommands:\n", buff.String()) } From 6fb53a406bde2230fbb016785119bbeae0b05713 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:18:51 +0100 Subject: [PATCH 25/83] remove unusued expectations --- task_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/task_test.go b/task_test.go index e9866607..548d937d 100644 --- a/task_test.go +++ b/task_test.go @@ -586,9 +586,6 @@ func TestDetails(t *testing.T) { assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) assert.Equal(t, string(exp), buff.String()) - assert.NotContains(t, buff.String(), "task-with-details was executed") - assert.NotContains(t, buff.String(), "dependend-task was executed") - buff.Reset() const noDetails = "task-without-details" assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: noDetails})) From b2edbf05a111ca6aac0bbf1c57181526b4e41e61 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:20:39 +0100 Subject: [PATCH 26/83] refactoring --- task_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/task_test.go b/task_test.go index 548d937d..d98e0f0f 100644 --- a/task_test.go +++ b/task_test.go @@ -580,8 +580,7 @@ func TestDetails(t *testing.T) { } assert.NoError(t, e.Setup()) - exp, err := ioutil.ReadFile(dir + "/expected-task-with-details-details.txt") - assert.NoError(t, err, "error reading text fixture") + exp := readTestFixture(t, dir, "expected-task-with-details-details.txt") assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) assert.Equal(t, string(exp), buff.String()) @@ -603,3 +602,9 @@ func TestDetails(t *testing.T) { assert.Equal(t, "task: task-with-description-containing-empty-line\n\nFirst line followed by empty line\n\nLast Line\n\ncommands:\n", buff.String()) } + +func readTestFixture(t *testing.T, dir string, file string) []byte { + exp, err := ioutil.ReadFile(dir + "/" + file) + assert.NoError(t, err, "error reading text fixture") + return exp +} From 8dd87dc4820e953277e30cd3ce786c61bd5a81f7 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:23:44 +0100 Subject: [PATCH 27/83] refactoring --- task_test.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/task_test.go b/task_test.go index d98e0f0f..63fb84ba 100644 --- a/task_test.go +++ b/task_test.go @@ -579,11 +579,8 @@ func TestDetails(t *testing.T) { Silent: true, } assert.NoError(t, e.Setup()) - - exp := readTestFixture(t, dir, "expected-task-with-details-details.txt") - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) - assert.Equal(t, string(exp), buff.String()) + assert.Equal(t, readTestFixture(t, dir, "expected-task-with-details-details.txt"), buff.String()) buff.Reset() const noDetails = "task-without-details" @@ -603,8 +600,8 @@ func TestDetails(t *testing.T) { } -func readTestFixture(t *testing.T, dir string, file string) []byte { - exp, err := ioutil.ReadFile(dir + "/" + file) +func readTestFixture(t *testing.T, dir string, file string) string { + b, err := ioutil.ReadFile(dir + "/" + file) assert.NoError(t, err, "error reading text fixture") - return exp + return string(b) } From 1054c89a9de574a63b12583260de4acb770ea715 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:24:55 +0100 Subject: [PATCH 28/83] add missing test fixture file --- testdata/details/expected-task-with-details-details.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 testdata/details/expected-task-with-details-details.txt diff --git a/testdata/details/expected-task-with-details-details.txt b/testdata/details/expected-task-with-details-details.txt new file mode 100644 index 00000000..4b73a359 --- /dev/null +++ b/testdata/details/expected-task-with-details-details.txt @@ -0,0 +1,7 @@ +task: task-with-details + +details of task-with-details - line 1 +line 2 +line 3 + +commands: From fb666394fc4e05d0ac62807614ba13f3d70a9afa Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:31:29 +0100 Subject: [PATCH 29/83] refatoring --- task_test.go | 2 +- ...xpected-task-with-description-containing-empty-line.txt | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 testdata/details/expected-task-with-description-containing-empty-line.txt diff --git a/task_test.go b/task_test.go index 63fb84ba..e5de3356 100644 --- a/task_test.go +++ b/task_test.go @@ -596,7 +596,7 @@ 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, "task: task-with-description-containing-empty-line\n\nFirst line followed by empty line\n\nLast Line\n\ncommands:\n", buff.String()) + assert.Equal(t, readTestFixture(t, dir, "expected-task-with-description-containing-empty-line.txt"), buff.String()) } diff --git a/testdata/details/expected-task-with-description-containing-empty-line.txt b/testdata/details/expected-task-with-description-containing-empty-line.txt new file mode 100644 index 00000000..64d87c6c --- /dev/null +++ b/testdata/details/expected-task-with-description-containing-empty-line.txt @@ -0,0 +1,7 @@ +task: task-with-description-containing-empty-line + +First line followed by empty line + +Last Line + +commands: From db1d3183b6d7b71a803669960817639087ac713f Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:32:47 +0100 Subject: [PATCH 30/83] refatoring --- task_test.go | 4 ++-- ...ne.txt => task-with-description-containing-empty-line.txt} | 0 ...with-details-details.txt => task-with-details-details.txt} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename testdata/details/{expected-task-with-description-containing-empty-line.txt => task-with-description-containing-empty-line.txt} (100%) rename testdata/details/{expected-task-with-details-details.txt => task-with-details-details.txt} (100%) diff --git a/task_test.go b/task_test.go index e5de3356..aa473e63 100644 --- a/task_test.go +++ b/task_test.go @@ -580,7 +580,7 @@ func TestDetails(t *testing.T) { } assert.NoError(t, e.Setup()) assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) - assert.Equal(t, readTestFixture(t, dir, "expected-task-with-details-details.txt"), buff.String()) + assert.Equal(t, readTestFixture(t, dir, "task-with-details-details.txt"), buff.String()) buff.Reset() const noDetails = "task-without-details" @@ -596,7 +596,7 @@ 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, readTestFixture(t, dir, "expected-task-with-description-containing-empty-line.txt"), buff.String()) + assert.Equal(t, readTestFixture(t, dir, "task-with-description-containing-empty-line.txt"), buff.String()) } diff --git a/testdata/details/expected-task-with-description-containing-empty-line.txt b/testdata/details/task-with-description-containing-empty-line.txt similarity index 100% rename from testdata/details/expected-task-with-description-containing-empty-line.txt rename to testdata/details/task-with-description-containing-empty-line.txt diff --git a/testdata/details/expected-task-with-details-details.txt b/testdata/details/task-with-details-details.txt similarity index 100% rename from testdata/details/expected-task-with-details-details.txt rename to testdata/details/task-with-details-details.txt From 0446cfdba056adb01170e8f2bf58ca7e9dccff2f Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:37:14 +0100 Subject: [PATCH 31/83] display commands of task --- task.go | 7 ++++++- testdata/details/Taskfile.yml | 2 ++ .../task-with-description-containing-empty-line.txt | 1 + testdata/details/task-with-details-details.txt | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/task.go b/task.go index dd0dce24..8936f462 100644 --- a/task.go +++ b/task.go @@ -82,7 +82,8 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } func (e *Executor) printTaskDetails(task string) { - s := e.Taskfile.Tasks[task].Details + t := e.Taskfile.Tasks[task] + s := t.Details if s == "" { e.Logger.Errf("task: There is no detailed description for task: %s", task) return @@ -96,6 +97,10 @@ func (e *Executor) printTaskDetails(task string) { e.Logger.Outf("") e.Logger.Outf("commands:") + + for _, c := range t.Cmds { + e.Logger.Outf(" - %s", c.Cmd) + } } func displayTaskDetailedDescription(description string, Logger *logger.Logger) { diff --git a/testdata/details/Taskfile.yml b/testdata/details/Taskfile.yml index d2b1ec49..e5e3b0e2 100644 --- a/testdata/details/Taskfile.yml +++ b/testdata/details/Taskfile.yml @@ -8,6 +8,8 @@ tasks: line 3 cmds: - echo 'task-with-details was executed' + - echo 'another command' + - exit 0 task-without-details: deps: [dependend-task] diff --git a/testdata/details/task-with-description-containing-empty-line.txt b/testdata/details/task-with-description-containing-empty-line.txt index 64d87c6c..6915ebe7 100644 --- a/testdata/details/task-with-description-containing-empty-line.txt +++ b/testdata/details/task-with-description-containing-empty-line.txt @@ -5,3 +5,4 @@ First line followed by empty line Last Line commands: + - exit 0 diff --git a/testdata/details/task-with-details-details.txt b/testdata/details/task-with-details-details.txt index 4b73a359..9e327a50 100644 --- a/testdata/details/task-with-details-details.txt +++ b/testdata/details/task-with-details-details.txt @@ -5,3 +5,6 @@ line 2 line 3 commands: + - echo 'task-with-details was executed' + - echo 'another command' + - exit 0 From 1c3082ffa6cc0a5a72f897bf1ff5783f4b53aa9f Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:48:48 +0100 Subject: [PATCH 32/83] rename test fixture --- task_test.go | 2 +- .../{task-with-details-details.txt => task-with-details.txt} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename testdata/details/{task-with-details-details.txt => task-with-details.txt} (100%) diff --git a/task_test.go b/task_test.go index aa473e63..eb66e976 100644 --- a/task_test.go +++ b/task_test.go @@ -580,7 +580,7 @@ func TestDetails(t *testing.T) { } assert.NoError(t, e.Setup()) assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) - assert.Equal(t, readTestFixture(t, dir, "task-with-details-details.txt"), buff.String()) + assert.Equal(t, readTestFixture(t, dir, "task-with-details.txt"), buff.String()) buff.Reset() const noDetails = "task-without-details" diff --git a/testdata/details/task-with-details-details.txt b/testdata/details/task-with-details.txt similarity index 100% rename from testdata/details/task-with-details-details.txt rename to testdata/details/task-with-details.txt From 4b3cea3812b0e2624c5d6f506d5f22607ce51701 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:53:39 +0100 Subject: [PATCH 33/83] display dependend tasks --- task.go | 7 +++++++ testdata/details/Taskfile.yml | 10 +++++++--- .../task-with-description-containing-empty-line.txt | 2 ++ testdata/details/task-with-details.txt | 4 ++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/task.go b/task.go index 8936f462..e1e2ca4c 100644 --- a/task.go +++ b/task.go @@ -95,6 +95,13 @@ func (e *Executor) printTaskDetails(task string) { Logger := e.Logger displayTaskDetailedDescription(s, Logger) + e.Logger.Outf("") + e.Logger.Outf("dependencies:") + + for _, d := range t.Deps { + e.Logger.Outf(" - %s", d.Task) + } + e.Logger.Outf("") e.Logger.Outf("commands:") diff --git a/testdata/details/Taskfile.yml b/testdata/details/Taskfile.yml index e5e3b0e2..fae4579b 100644 --- a/testdata/details/Taskfile.yml +++ b/testdata/details/Taskfile.yml @@ -1,7 +1,7 @@ version: 2 tasks: task-with-details: - deps: [dependend-task] + deps: [dependend-task-1,dependend-task-2] details: | details of task-with-details - line 1 line 2 @@ -16,9 +16,13 @@ tasks: cmds: - echo 'task-without-details was executed' - dependend-task: + dependend-task-1: cmds: - - echo 'dependend-task was executed' + - echo 'dependend-task-1 was executed' + - + dependend-task-2: + cmds: + - echo 'dependend-task-2 was executed' other-task-with-details: details: details of other-task-with-details diff --git a/testdata/details/task-with-description-containing-empty-line.txt b/testdata/details/task-with-description-containing-empty-line.txt index 6915ebe7..f47ff01e 100644 --- a/testdata/details/task-with-description-containing-empty-line.txt +++ b/testdata/details/task-with-description-containing-empty-line.txt @@ -4,5 +4,7 @@ First line followed by empty line Last Line +dependencies: + commands: - exit 0 diff --git a/testdata/details/task-with-details.txt b/testdata/details/task-with-details.txt index 9e327a50..437d85cb 100644 --- a/testdata/details/task-with-details.txt +++ b/testdata/details/task-with-details.txt @@ -4,6 +4,10 @@ details of task-with-details - line 1 line 2 line 3 +dependencies: + - dependend-task-1 + - dependend-task-2 + commands: - echo 'task-with-details was executed' - echo 'another command' From fdbc130d8d70e5069d4f10776bb4d55c7d6d581d Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:55:04 +0100 Subject: [PATCH 34/83] do not show empty dependencies --- task.go | 10 ++++++---- .../task-with-description-containing-empty-line.txt | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/task.go b/task.go index e1e2ca4c..be51a21d 100644 --- a/task.go +++ b/task.go @@ -95,11 +95,13 @@ func (e *Executor) printTaskDetails(task string) { Logger := e.Logger displayTaskDetailedDescription(s, Logger) - e.Logger.Outf("") - e.Logger.Outf("dependencies:") + if len(t.Deps) > 0 { + e.Logger.Outf("") + e.Logger.Outf("dependencies:") - for _, d := range t.Deps { - e.Logger.Outf(" - %s", d.Task) + for _, d := range t.Deps { + e.Logger.Outf(" - %s", d.Task) + } } e.Logger.Outf("") diff --git a/testdata/details/task-with-description-containing-empty-line.txt b/testdata/details/task-with-description-containing-empty-line.txt index f47ff01e..6915ebe7 100644 --- a/testdata/details/task-with-description-containing-empty-line.txt +++ b/testdata/details/task-with-description-containing-empty-line.txt @@ -4,7 +4,5 @@ First line followed by empty line Last Line -dependencies: - commands: - exit 0 From a1837d553e1189365a4c5bc0bdf621012ff4ee9e Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 14:59:19 +0100 Subject: [PATCH 35/83] refactoring --- task.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/task.go b/task.go index be51a21d..ca343519 100644 --- a/task.go +++ b/task.go @@ -92,17 +92,8 @@ func (e *Executor) printTaskDetails(task string) { e.Logger.Outf("task: " + task) e.Logger.Outf("") - Logger := e.Logger - displayTaskDetailedDescription(s, Logger) - - if len(t.Deps) > 0 { - e.Logger.Outf("") - e.Logger.Outf("dependencies:") - - for _, d := range t.Deps { - e.Logger.Outf(" - %s", d.Task) - } - } + printTaskDetailedDescription(s, e.Logger) + printDependencies(t.Deps, e.Logger) e.Logger.Outf("") e.Logger.Outf("commands:") @@ -112,7 +103,19 @@ func (e *Executor) printTaskDetails(task string) { } } -func displayTaskDetailedDescription(description string, Logger *logger.Logger) { +func printDependencies(deps []*taskfile.Dep, logger *logger.Logger) { + hasDependencies := len(deps) > 0 + if hasDependencies { + logger.Outf("") + logger.Outf("dependencies:") + + for _, d := range deps { + logger.Outf(" - %s", d.Task) + } + } +} + +func printTaskDetailedDescription(description string, Logger *logger.Logger) { lines := strings.Split(description, "\n") for i, line := range lines { notLastLine := i+1 < len(lines) @@ -120,6 +123,7 @@ func displayTaskDetailedDescription(description string, Logger *logger.Logger) { Logger.Outf(line) } } + } // Setup setups Executor's internal state From 2676ab9a592e2548092393abcde15f7b4061adfe Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 15:31:46 +0100 Subject: [PATCH 36/83] renamed program flag to summary --- cmd/task/task.go | 6 +++--- task.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/task/task.go b/cmd/task/task.go index 4140c5d7..43a35954 100644 --- a/cmd/task/task.go +++ b/cmd/task/task.go @@ -56,7 +56,7 @@ func main() { verbose bool silent bool dry bool - details bool + summary bool dir string output string ) @@ -70,7 +70,7 @@ func main() { pflag.BoolVarP(&verbose, "verbose", "v", false, "enables verbose mode") pflag.BoolVarP(&silent, "silent", "s", false, "disables echoing") pflag.BoolVar(&dry, "dry", false, "compiles and prints tasks in the order that they would be run, without executing them") - pflag.BoolVar(&details, "details", false, "show detailed description about a task if present") + pflag.BoolVar(&summary, "summary", false, "show summary about a task") pflag.StringVarP(&dir, "dir", "d", "", "sets directory of execution") pflag.StringVarP(&output, "output", "o", "", "sets output style: [interleaved|group|prefixed]") pflag.Parse() @@ -98,7 +98,7 @@ func main() { Silent: silent, Dir: dir, Dry: dry, - Details: details, + Details: summary, Stdin: os.Stdin, Stdout: os.Stdout, diff --git a/task.go b/task.go index ca343519..31c6b072 100644 --- a/task.go +++ b/task.go @@ -93,7 +93,7 @@ func (e *Executor) printTaskDetails(task string) { e.Logger.Outf("") printTaskDetailedDescription(s, e.Logger) - printDependencies(t.Deps, e.Logger) + printTaskDependencies(t.Deps, e.Logger) e.Logger.Outf("") e.Logger.Outf("commands:") @@ -103,7 +103,7 @@ func (e *Executor) printTaskDetails(task string) { } } -func printDependencies(deps []*taskfile.Dep, logger *logger.Logger) { +func printTaskDependencies(deps []*taskfile.Dep, logger *logger.Logger) { hasDependencies := len(deps) > 0 if hasDependencies { logger.Outf("") From 9a3b7260688658cfbf1c82a2ad0bc7e36b38f542 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 15:32:17 +0100 Subject: [PATCH 37/83] change help to summary --- cmd/task/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/task/task.go b/cmd/task/task.go index 43a35954..2525c97d 100644 --- a/cmd/task/task.go +++ b/cmd/task/task.go @@ -17,7 +17,7 @@ var ( version = "master" ) -const usage = `Usage: task [-ilfwvsd] [--init] [--list] [--force] [--watch] [--verbose] [--silent] [--dir] [--dry] [--details] [task...] +const usage = `Usage: task [-ilfwvsd] [--init] [--list] [--force] [--watch] [--verbose] [--silent] [--dir] [--dry] [--summary] [task...] Runs the specified task(s). Falls back to the "default" task if no task name was specified, or lists all tasks if an unknown task name was specified. From 06d0af7a1dd7d230199defc89b60567874207909 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 15:33:09 +0100 Subject: [PATCH 38/83] rename details in Executor to summary --- cmd/task/task.go | 2 +- task.go | 4 ++-- task_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/task/task.go b/cmd/task/task.go index 2525c97d..2e853580 100644 --- a/cmd/task/task.go +++ b/cmd/task/task.go @@ -98,7 +98,7 @@ func main() { Silent: silent, Dir: dir, Dry: dry, - Details: summary, + Summary: summary, Stdin: os.Stdin, Stdout: os.Stdout, diff --git a/task.go b/task.go index 31c6b072..1e01f223 100644 --- a/task.go +++ b/task.go @@ -37,7 +37,7 @@ type Executor struct { Verbose bool Silent bool Dry bool - Details bool + Summary bool Stdin io.Reader Stdout io.Writer @@ -64,7 +64,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } } - if e.Details { + if e.Summary { e.printTaskDetails(calls[0].Task) return nil } diff --git a/task_test.go b/task_test.go index eb66e976..ba3179d6 100644 --- a/task_test.go +++ b/task_test.go @@ -575,7 +575,7 @@ func TestDetails(t *testing.T) { Dir: dir, Stdout: &buff, Stderr: &buff, - Details: true, + Summary: true, Silent: true, } assert.NoError(t, e.Setup()) From d05d418c4c73d2c8f03dddb6b40418787788a3ee Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 15:37:02 +0100 Subject: [PATCH 39/83] renaming field in taskfile to summary --- internal/taskfile/task.go | 2 +- task.go | 2 +- task_test.go | 10 +++++----- testdata/{details => summary}/Taskfile.yml | 6 +++--- .../task-with-description-containing-empty-line.txt | 0 testdata/{details => summary}/task-with-details.txt | 0 6 files changed, 10 insertions(+), 10 deletions(-) rename testdata/{details => summary}/Taskfile.yml (90%) rename testdata/{details => summary}/task-with-description-containing-empty-line.txt (100%) rename testdata/{details => summary}/task-with-details.txt (100%) diff --git a/internal/taskfile/task.go b/internal/taskfile/task.go index 0bd63b26..1afcbfa3 100644 --- a/internal/taskfile/task.go +++ b/internal/taskfile/task.go @@ -9,7 +9,7 @@ type Task struct { Cmds []*Cmd Deps []*Dep Desc string - Details string + Summary string Sources []string Generates []string Status []string diff --git a/task.go b/task.go index 1e01f223..c47ec7f0 100644 --- a/task.go +++ b/task.go @@ -83,7 +83,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { func (e *Executor) printTaskDetails(task string) { t := e.Taskfile.Tasks[task] - s := t.Details + s := t.Summary if s == "" { e.Logger.Errf("task: There is no detailed description for task: %s", task) return diff --git a/task_test.go b/task_test.go index ba3179d6..bbbd4d0e 100644 --- a/task_test.go +++ b/task_test.go @@ -555,20 +555,20 @@ func TestIncludesCallingRoot(t *testing.T) { } func TestDetailsParsing(t *testing.T) { - const dir = "testdata/details" + const dir = "testdata/summary" e := task.Executor{ Dir: dir, } assert.NoError(t, e.Setup()) - assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, "details of task-with-details - line 1\nline 2\nline 3\n") - assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Details, "details of other-task-with-details") - assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Details, "") + assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Summary, "details of task-with-details - line 1\nline 2\nline 3\n") + assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Summary, "details of other-task-with-details") + assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Summary, "") } func TestDetails(t *testing.T) { - const dir = "testdata/details" + const dir = "testdata/summary" var buff bytes.Buffer e := task.Executor{ diff --git a/testdata/details/Taskfile.yml b/testdata/summary/Taskfile.yml similarity index 90% rename from testdata/details/Taskfile.yml rename to testdata/summary/Taskfile.yml index fae4579b..bca2dca3 100644 --- a/testdata/details/Taskfile.yml +++ b/testdata/summary/Taskfile.yml @@ -2,7 +2,7 @@ version: 2 tasks: task-with-details: deps: [dependend-task-1,dependend-task-2] - details: | + summary: | details of task-with-details - line 1 line 2 line 3 @@ -25,12 +25,12 @@ tasks: - echo 'dependend-task-2 was executed' other-task-with-details: - details: details of other-task-with-details + summary: details of other-task-with-details cmds: - echo 'other-task-with-details was executed' task-with-description-containing-empty-line: - details: | + summary: | First line followed by empty line Last Line diff --git a/testdata/details/task-with-description-containing-empty-line.txt b/testdata/summary/task-with-description-containing-empty-line.txt similarity index 100% rename from testdata/details/task-with-description-containing-empty-line.txt rename to testdata/summary/task-with-description-containing-empty-line.txt diff --git a/testdata/details/task-with-details.txt b/testdata/summary/task-with-details.txt similarity index 100% rename from testdata/details/task-with-details.txt rename to testdata/summary/task-with-details.txt From 33d4ad4d8455bec25562e7ac1d7693a4db6b2bb1 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 15:38:18 +0100 Subject: [PATCH 40/83] rename to summary --- task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.go b/task.go index c47ec7f0..4506bd2e 100644 --- a/task.go +++ b/task.go @@ -65,7 +65,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } if e.Summary { - e.printTaskDetails(calls[0].Task) + e.printTaskSummary(calls[0].Task) return nil } @@ -81,7 +81,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { return nil } -func (e *Executor) printTaskDetails(task string) { +func (e *Executor) printTaskSummary(task string) { t := e.Taskfile.Tasks[task] s := t.Summary if s == "" { From 9e9ffeb5d5e9fbb27caf5637dcd88d7ff05941c0 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 15:43:45 +0100 Subject: [PATCH 41/83] refactoring --- task.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/task.go b/task.go index 4506bd2e..272fb118 100644 --- a/task.go +++ b/task.go @@ -96,10 +96,13 @@ func (e *Executor) printTaskSummary(task string) { printTaskDependencies(t.Deps, e.Logger) e.Logger.Outf("") - e.Logger.Outf("commands:") + printCommands(t.Cmds, e.Logger) +} - for _, c := range t.Cmds { - e.Logger.Outf(" - %s", c.Cmd) +func printCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { + logger.Outf("commands:") + for _, c := range cmds { + logger.Outf(" - %s", c.Cmd) } } From 3999480d64da3fd5151cf3083113caf07b91747d Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 15:45:39 +0100 Subject: [PATCH 42/83] refactoring --- task.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/task.go b/task.go index 272fb118..0c970cd9 100644 --- a/task.go +++ b/task.go @@ -92,10 +92,8 @@ func (e *Executor) printTaskSummary(task string) { e.Logger.Outf("task: " + task) e.Logger.Outf("") - printTaskDetailedDescription(s, e.Logger) + printTaskSummary(s, e.Logger) printTaskDependencies(t.Deps, e.Logger) - - e.Logger.Outf("") printCommands(t.Cmds, e.Logger) } @@ -116,9 +114,10 @@ func printTaskDependencies(deps []*taskfile.Dep, logger *logger.Logger) { logger.Outf(" - %s", d.Task) } } + logger.Outf("") } -func printTaskDetailedDescription(description string, Logger *logger.Logger) { +func printTaskSummary(description string, Logger *logger.Logger) { lines := strings.Split(description, "\n") for i, line := range lines { notLastLine := i+1 < len(lines) @@ -126,7 +125,6 @@ func printTaskDetailedDescription(description string, Logger *logger.Logger) { Logger.Outf(line) } } - } // Setup setups Executor's internal state From 31ecf167ccb5c3f2af75ae0fb44dc3a64f16f471 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 15:54:11 +0100 Subject: [PATCH 43/83] rename to summary in test fixtures --- task.go | 2 +- task_test.go | 32 +++++++++---------- testdata/summary/Taskfile.yml | 18 +++++------ ...sk-with-summary-containing-empty-line.txt} | 2 +- ...with-details.txt => task-with-summary.txt} | 6 ++-- 5 files changed, 30 insertions(+), 30 deletions(-) rename testdata/summary/{task-with-description-containing-empty-line.txt => task-with-summary-containing-empty-line.txt} (57%) rename testdata/summary/{task-with-details.txt => task-with-summary.txt} (53%) diff --git a/task.go b/task.go index 0c970cd9..1a68ada2 100644 --- a/task.go +++ b/task.go @@ -85,7 +85,7 @@ func (e *Executor) printTaskSummary(task string) { t := e.Taskfile.Tasks[task] s := t.Summary if s == "" { - e.Logger.Errf("task: There is no detailed description for task: %s", task) + e.Logger.Errf("task: There is no summary for task: %s", task) return } diff --git a/task_test.go b/task_test.go index bbbd4d0e..9a51886f 100644 --- a/task_test.go +++ b/task_test.go @@ -554,7 +554,7 @@ func TestIncludesCallingRoot(t *testing.T) { tt.Run(t) } -func TestDetailsParsing(t *testing.T) { +func TestSummaryParsing(t *testing.T) { const dir = "testdata/summary" e := task.Executor{ @@ -562,12 +562,12 @@ func TestDetailsParsing(t *testing.T) { } assert.NoError(t, e.Setup()) - assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Summary, "details of task-with-details - line 1\nline 2\nline 3\n") - assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Summary, "details of other-task-with-details") - assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Summary, "") + assert.Equal(t, e.Taskfile.Tasks["task-with-summary"].Summary, "summary of task-with-summary - line 1\nline 2\nline 3\n") + assert.Equal(t, e.Taskfile.Tasks["other-task-with-summary"].Summary, "summary of other-task-with-summary") + assert.Equal(t, e.Taskfile.Tasks["task-without-summary"].Summary, "") } -func TestDetails(t *testing.T) { +func TestSummary(t *testing.T) { const dir = "testdata/summary" var buff bytes.Buffer @@ -579,24 +579,24 @@ func TestDetails(t *testing.T) { Silent: true, } assert.NoError(t, e.Setup()) - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) - assert.Equal(t, readTestFixture(t, dir, "task-with-details.txt"), buff.String()) + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary"})) + assert.Equal(t, readTestFixture(t, dir, "task-with-summary.txt"), buff.String()) buff.Reset() - const noDetails = "task-without-details" - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: noDetails})) - assert.Equal(t, "task: There is no detailed description for task: "+noDetails+"\n", buff.String()) + const nosummary = "task-without-summary" + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: nosummary})) + assert.Equal(t, "task: There is no summary for task: "+nosummary+"\n", buff.String()) buff.Reset() - const firstTask = "other-task-with-details" - const secondTask = "task-with-details" + const firstTask = "other-task-with-summary" + const secondTask = "task-with-summary" assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: firstTask}, taskfile.Call{Task: secondTask})) - assert.Contains(t, buff.String(), "details of "+firstTask) - assert.NotContains(t, buff.String(), "details of "+secondTask) + assert.Contains(t, buff.String(), "summary of "+firstTask) + assert.NotContains(t, buff.String(), "summary of "+secondTask) buff.Reset() - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-description-containing-empty-line"})) - assert.Equal(t, readTestFixture(t, dir, "task-with-description-containing-empty-line.txt"), buff.String()) + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary-containing-empty-line"})) + assert.Equal(t, readTestFixture(t, dir, "task-with-summary-containing-empty-line.txt"), buff.String()) } diff --git a/testdata/summary/Taskfile.yml b/testdata/summary/Taskfile.yml index bca2dca3..28cec378 100644 --- a/testdata/summary/Taskfile.yml +++ b/testdata/summary/Taskfile.yml @@ -1,20 +1,20 @@ version: 2 tasks: - task-with-details: + task-with-summary: deps: [dependend-task-1,dependend-task-2] summary: | - details of task-with-details - line 1 + summary of task-with-summary - line 1 line 2 line 3 cmds: - - echo 'task-with-details was executed' + - echo 'task-with-summary was executed' - echo 'another command' - exit 0 - task-without-details: + task-without-summary: deps: [dependend-task] cmds: - - echo 'task-without-details was executed' + - echo 'task-without-summary was executed' dependend-task-1: cmds: @@ -24,12 +24,12 @@ tasks: cmds: - echo 'dependend-task-2 was executed' - other-task-with-details: - summary: details of other-task-with-details + other-task-with-summary: + summary: summary of other-task-with-summary cmds: - - echo 'other-task-with-details was executed' + - echo 'other-task-with-summary was executed' - task-with-description-containing-empty-line: + task-with-summary-containing-empty-line: summary: | First line followed by empty line diff --git a/testdata/summary/task-with-description-containing-empty-line.txt b/testdata/summary/task-with-summary-containing-empty-line.txt similarity index 57% rename from testdata/summary/task-with-description-containing-empty-line.txt rename to testdata/summary/task-with-summary-containing-empty-line.txt index 6915ebe7..8eca5e86 100644 --- a/testdata/summary/task-with-description-containing-empty-line.txt +++ b/testdata/summary/task-with-summary-containing-empty-line.txt @@ -1,4 +1,4 @@ -task: task-with-description-containing-empty-line +task: task-with-summary-containing-empty-line First line followed by empty line diff --git a/testdata/summary/task-with-details.txt b/testdata/summary/task-with-summary.txt similarity index 53% rename from testdata/summary/task-with-details.txt rename to testdata/summary/task-with-summary.txt index 437d85cb..c01eba06 100644 --- a/testdata/summary/task-with-details.txt +++ b/testdata/summary/task-with-summary.txt @@ -1,6 +1,6 @@ -task: task-with-details +task: task-with-summary -details of task-with-details - line 1 +summary of task-with-summary - line 1 line 2 line 3 @@ -9,6 +9,6 @@ dependencies: - dependend-task-2 commands: - - echo 'task-with-details was executed' + - echo 'task-with-summary was executed' - echo 'another command' - exit 0 From 4dcb1246933f4189309b0d873fcae86dd2e501f5 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 16:08:32 +0100 Subject: [PATCH 44/83] print commands on summary only if commands are present --- task.go | 11 +++++++---- task_test.go | 17 ++++------------- testdata/summary/Taskfile.yml | 6 +++++- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/task.go b/task.go index 1a68ada2..6e26d5c2 100644 --- a/task.go +++ b/task.go @@ -98,9 +98,13 @@ func (e *Executor) printTaskSummary(task string) { } func printCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { - logger.Outf("commands:") - for _, c := range cmds { - logger.Outf(" - %s", c.Cmd) + hasCommands := len(cmds) > 0 + if hasCommands { + logger.Outf("") + logger.Outf("commands:") + for _, c := range cmds { + logger.Outf(" - %s", c.Cmd) + } } } @@ -114,7 +118,6 @@ func printTaskDependencies(deps []*taskfile.Dep, logger *logger.Logger) { logger.Outf(" - %s", d.Task) } } - logger.Outf("") } func printTaskSummary(description string, Logger *logger.Logger) { diff --git a/task_test.go b/task_test.go index 9a51886f..a3636826 100644 --- a/task_test.go +++ b/task_test.go @@ -554,19 +554,6 @@ func TestIncludesCallingRoot(t *testing.T) { tt.Run(t) } -func TestSummaryParsing(t *testing.T) { - const dir = "testdata/summary" - - e := task.Executor{ - Dir: dir, - } - assert.NoError(t, e.Setup()) - - assert.Equal(t, e.Taskfile.Tasks["task-with-summary"].Summary, "summary of task-with-summary - line 1\nline 2\nline 3\n") - assert.Equal(t, e.Taskfile.Tasks["other-task-with-summary"].Summary, "summary of other-task-with-summary") - assert.Equal(t, e.Taskfile.Tasks["task-without-summary"].Summary, "") -} - func TestSummary(t *testing.T) { const dir = "testdata/summary" @@ -598,6 +585,10 @@ func TestSummary(t *testing.T) { assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary-containing-empty-line"})) assert.Equal(t, readTestFixture(t, dir, "task-with-summary-containing-empty-line.txt"), buff.String()) + buff.Reset() + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-without-commands"})) + assert.Equal(t, readTestFixture(t, dir, "task-without-commands.txt"), buff.String()) + } func readTestFixture(t *testing.T, dir string, file string) string { diff --git a/testdata/summary/Taskfile.yml b/testdata/summary/Taskfile.yml index 28cec378..2a7fcdaf 100644 --- a/testdata/summary/Taskfile.yml +++ b/testdata/summary/Taskfile.yml @@ -12,7 +12,7 @@ tasks: - exit 0 task-without-summary: - deps: [dependend-task] + deps: [dependend-task-1] cmds: - echo 'task-without-summary was executed' @@ -36,3 +36,7 @@ tasks: Last Line cmds: - exit 0 + + task-without-commands: + summary: summary + deps: [dependend-task-1] From 80f5cee5993affcbf5d51619fd974902ad527f79 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 16:10:43 +0100 Subject: [PATCH 45/83] refactoring --- testdata/summary/Taskfile.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/testdata/summary/Taskfile.yml b/testdata/summary/Taskfile.yml index 2a7fcdaf..10f152c0 100644 --- a/testdata/summary/Taskfile.yml +++ b/testdata/summary/Taskfile.yml @@ -1,5 +1,7 @@ version: 2 + tasks: + task-with-summary: deps: [dependend-task-1,dependend-task-2] summary: | @@ -16,14 +18,6 @@ tasks: cmds: - echo 'task-without-summary was executed' - dependend-task-1: - cmds: - - echo 'dependend-task-1 was executed' - - - dependend-task-2: - cmds: - - echo 'dependend-task-2 was executed' - other-task-with-summary: summary: summary of other-task-with-summary cmds: @@ -35,8 +29,16 @@ tasks: Last Line cmds: - - exit 0 + - exit 0 task-without-commands: summary: summary deps: [dependend-task-1] + + dependend-task-1: + cmds: + - echo 'dependend-task-1 was executed' + - + dependend-task-2: + cmds: + - echo 'dependend-task-2 was executed' From 765e3dbf72fe2d616137816b01c45bce539c8aee Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 16:15:59 +0100 Subject: [PATCH 46/83] print only commands if present --- testdata/summary/Taskfile.yml | 1 - testdata/summary/task-without-commands.txt | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 testdata/summary/task-without-commands.txt diff --git a/testdata/summary/Taskfile.yml b/testdata/summary/Taskfile.yml index 10f152c0..cf07e9df 100644 --- a/testdata/summary/Taskfile.yml +++ b/testdata/summary/Taskfile.yml @@ -38,7 +38,6 @@ tasks: dependend-task-1: cmds: - echo 'dependend-task-1 was executed' - - dependend-task-2: cmds: - echo 'dependend-task-2 was executed' diff --git a/testdata/summary/task-without-commands.txt b/testdata/summary/task-without-commands.txt new file mode 100644 index 00000000..c7c5b024 --- /dev/null +++ b/testdata/summary/task-without-commands.txt @@ -0,0 +1,6 @@ +task: task-without-commands + +summary + +dependencies: + - dependend-task-1 From a1765e1d3370cdcfd1a8252ce3274741c9363c87 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 16:17:47 +0100 Subject: [PATCH 47/83] refactoring --- task.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/task.go b/task.go index 6e26d5c2..2c18469f 100644 --- a/task.go +++ b/task.go @@ -65,7 +65,8 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } if e.Summary { - e.printTaskSummary(calls[0].Task) + firstTask := calls[0].Task + e.printTaskSummary(firstTask) return nil } From 3ee66ef7057373814530ecbb5c8b91749703174e Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 16:25:27 +0100 Subject: [PATCH 48/83] remove output to own package --- internal/summary/summary.go | 48 +++++++++++++++++++++++++++++++++++++ task.go | 45 +++------------------------------- 2 files changed, 51 insertions(+), 42 deletions(-) create mode 100644 internal/summary/summary.go diff --git a/internal/summary/summary.go b/internal/summary/summary.go new file mode 100644 index 00000000..b9542cd7 --- /dev/null +++ b/internal/summary/summary.go @@ -0,0 +1,48 @@ +package summary + +import ( + "github.com/go-task/task/v2/internal/logger" + "github.com/go-task/task/v2/internal/taskfile" + "strings" +) + +func Print(Logger *logger.Logger, task *taskfile.Task) { + Logger.Outf("task: " + task.Task) + Logger.Outf("") + printTaskSummary(task.Summary, Logger) + printTaskDependencies(task.Deps, Logger) + printCommands(task.Cmds, Logger) +} + +func printCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { + hasCommands := len(cmds) > 0 + if hasCommands { + logger.Outf("") + logger.Outf("commands:") + for _, c := range cmds { + logger.Outf(" - %s", c.Cmd) + } + } +} + +func printTaskDependencies(deps []*taskfile.Dep, logger *logger.Logger) { + hasDependencies := len(deps) > 0 + if hasDependencies { + logger.Outf("") + logger.Outf("dependencies:") + + for _, d := range deps { + logger.Outf(" - %s", d.Task) + } + } +} + +func printTaskSummary(description string, Logger *logger.Logger) { + lines := strings.Split(description, "\n") + for i, line := range lines { + notLastLine := i+1 < len(lines) + if notLastLine || line != "" { + Logger.Outf(line) + } + } +} diff --git a/task.go b/task.go index 2c18469f..b85c8762 100644 --- a/task.go +++ b/task.go @@ -3,9 +3,9 @@ package task import ( "context" "fmt" + "github.com/go-task/task/v2/internal/summary" "io" "os" - "strings" "sync/atomic" "github.com/go-task/task/v2/internal/compiler" @@ -84,51 +84,12 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { func (e *Executor) printTaskSummary(task string) { t := e.Taskfile.Tasks[task] - s := t.Summary - if s == "" { + if t.Summary == "" { e.Logger.Errf("task: There is no summary for task: %s", task) return } - e.Logger.Outf("task: " + task) - e.Logger.Outf("") - - printTaskSummary(s, e.Logger) - printTaskDependencies(t.Deps, e.Logger) - printCommands(t.Cmds, e.Logger) -} - -func printCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { - hasCommands := len(cmds) > 0 - if hasCommands { - logger.Outf("") - logger.Outf("commands:") - for _, c := range cmds { - logger.Outf(" - %s", c.Cmd) - } - } -} - -func printTaskDependencies(deps []*taskfile.Dep, logger *logger.Logger) { - hasDependencies := len(deps) > 0 - if hasDependencies { - logger.Outf("") - logger.Outf("dependencies:") - - for _, d := range deps { - logger.Outf(" - %s", d.Task) - } - } -} - -func printTaskSummary(description string, Logger *logger.Logger) { - lines := strings.Split(description, "\n") - for i, line := range lines { - notLastLine := i+1 < len(lines) - if notLastLine || line != "" { - Logger.Outf(line) - } - } + summary.Print(e.Logger, t) } // Setup setups Executor's internal state From 24436ac76eba56a3541b23df72664fdffd28f5d0 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 16:26:46 +0100 Subject: [PATCH 49/83] refactoring --- internal/summary/summary.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index b9542cd7..a0202afc 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -7,14 +7,18 @@ import ( ) func Print(Logger *logger.Logger, task *taskfile.Task) { - Logger.Outf("task: " + task.Task) - Logger.Outf("") + printTaskName(Logger, task) printTaskSummary(task.Summary, Logger) printTaskDependencies(task.Deps, Logger) - printCommands(task.Cmds, Logger) + printTaskCommands(task.Cmds, Logger) } -func printCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { +func printTaskName(Logger *logger.Logger, task *taskfile.Task) { + Logger.Outf("task: " + task.Task) + Logger.Outf("") +} + +func printTaskCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { hasCommands := len(cmds) > 0 if hasCommands { logger.Outf("") From 33f389437203125707465dbf92f363602d9f9f2a Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 17:05:37 +0100 Subject: [PATCH 50/83] add unit tests for summary --- internal/summary/summary_test.go | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 internal/summary/summary_test.go diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go new file mode 100644 index 00000000..ed67d2d2 --- /dev/null +++ b/internal/summary/summary_test.go @@ -0,0 +1,49 @@ +package summary_test + +import ( + "bytes" + "github.com/go-task/task/v2/internal/logger" + "github.com/go-task/task/v2/internal/summary" + "github.com/go-task/task/v2/internal/taskfile" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestPrintsDependencies(t *testing.T) { + buffer := &bytes.Buffer{} + l := logger.Logger{ + Stdout: buffer, + Stderr: buffer, + Verbose: false, + } + task := &taskfile.Task{ + Deps: []*taskfile.Dep{ + {Task: "dep1"}, + {Task: "dep2"}, + {Task: "dep3"}, + }, + } + + summary.Print(&l, task) + + assert.Contains(t, buffer.String(), "\ndependencies:\n") + assert.Contains(t, buffer.String(), "\n - dep1\n") + assert.Contains(t, buffer.String(), "\n - dep2\n") + assert.Contains(t, buffer.String(), "\n - dep3\n") +} + +func TestDoesNotPrintDependencies(t *testing.T) { + buffer := &bytes.Buffer{} + l := logger.Logger{ + Stdout: buffer, + Stderr: buffer, + Verbose: false, + } + task := &taskfile.Task{ + Deps: []*taskfile.Dep{}, + } + + summary.Print(&l, task) + + assert.NotContains(t, buffer.String(), "dependencies:") +} From 474f27c6d3922ec77a2ebdc68696aeeef6300c47 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 17:10:59 +0100 Subject: [PATCH 51/83] add unit test for displaying commands --- internal/summary/summary_test.go | 43 ++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index ed67d2d2..2276be2b 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -9,7 +9,7 @@ import ( "testing" ) -func TestPrintsDependencies(t *testing.T) { +func TestPrintsDependenciesIfPresent(t *testing.T) { buffer := &bytes.Buffer{} l := logger.Logger{ Stdout: buffer, @@ -32,7 +32,7 @@ func TestPrintsDependencies(t *testing.T) { assert.Contains(t, buffer.String(), "\n - dep3\n") } -func TestDoesNotPrintDependencies(t *testing.T) { +func TestDoesNotPrintDependenciesIfMissing(t *testing.T) { buffer := &bytes.Buffer{} l := logger.Logger{ Stdout: buffer, @@ -47,3 +47,42 @@ func TestDoesNotPrintDependencies(t *testing.T) { assert.NotContains(t, buffer.String(), "dependencies:") } + +func TestPrintTaskName(t *testing.T) { + buffer := &bytes.Buffer{} + l := logger.Logger{ + Stdout: buffer, + Stderr: buffer, + Verbose: false, + } + task := &taskfile.Task{ + Task: "my-task-name", + } + + summary.Print(&l, task) + + assert.Contains(t, buffer.String(), "task: my-task-name\n") +} + +func TestPrintTaskCommandsIfPresent(t *testing.T) { + buffer := &bytes.Buffer{} + l := logger.Logger{ + Stdout: buffer, + Stderr: buffer, + Verbose: false, + } + task := &taskfile.Task{ + Cmds: []*taskfile.Cmd{ + {Cmd: "command-1"}, + {Cmd: "command-2"}, + {Cmd: "command-3"}, + }, + } + + summary.Print(&l, task) + + assert.Contains(t, buffer.String(), "\ncommands:\n") + assert.Contains(t, buffer.String(), "\n - command-1\n") + assert.Contains(t, buffer.String(), "\n - command-2\n") + assert.Contains(t, buffer.String(), "\n - command-3\n") +} From 890996f5956cbdc4cc4bd98cd246f59ba264ae54 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 17:12:22 +0100 Subject: [PATCH 52/83] hides commands keywoard if not present --- internal/summary/summary_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index 2276be2b..8ea4b1bb 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -86,3 +86,19 @@ func TestPrintTaskCommandsIfPresent(t *testing.T) { assert.Contains(t, buffer.String(), "\n - command-2\n") assert.Contains(t, buffer.String(), "\n - command-3\n") } + +func TestDoesNotPrintCommandIfMissing(t *testing.T) { + buffer := &bytes.Buffer{} + l := logger.Logger{ + Stdout: buffer, + Stderr: buffer, + Verbose: false, + } + task := &taskfile.Task{ + Cmds: []*taskfile.Cmd{}, + } + + summary.Print(&l, task) + + assert.NotContains(t, buffer.String(), "commands") +} From a4a20d92a4f1dcca92cc727dc1c3dd7e45dcc959 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 17:20:29 +0100 Subject: [PATCH 53/83] add unit test for full output --- internal/summary/summary_test.go | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index 8ea4b1bb..872d8dcf 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -102,3 +102,40 @@ func TestDoesNotPrintCommandIfMissing(t *testing.T) { assert.NotContains(t, buffer.String(), "commands") } + +func TestFullSummary(t *testing.T) { + buffer := &bytes.Buffer{} + l := logger.Logger{ + Stdout: buffer, + Stderr: buffer, + Verbose: false, + } + task := &taskfile.Task{ + Task: "sample-task", + Summary: "line1\nline2\nline3\n", + Deps: []*taskfile.Dep{ + {Task: "dependency"}, + }, + Cmds: []*taskfile.Cmd{ + {Cmd: "command"}, + }, + } + + summary.Print(&l, task) + + expected := + `task: sample-task + +line1 +line2 +line3 + +dependencies: + - dependency + +commands: + - command +` + + assert.Equal(t, expected, buffer.String()) +} From c82a7240bb14bde49cbbc82724be1db5ab0f5c5d Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 17:23:31 +0100 Subject: [PATCH 54/83] print task in command section --- internal/summary/summary.go | 6 +++++- internal/summary/summary_test.go | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index a0202afc..df864823 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -24,7 +24,11 @@ func printTaskCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { logger.Outf("") logger.Outf("commands:") for _, c := range cmds { - logger.Outf(" - %s", c.Cmd) + if c.Cmd != "" { + logger.Outf(" - %s", c.Cmd) + } else { + logger.Outf(" - Task: %s", c.Task) + } } } } diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index 872d8dcf..b64e1c7f 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -75,7 +75,7 @@ func TestPrintTaskCommandsIfPresent(t *testing.T) { Cmds: []*taskfile.Cmd{ {Cmd: "command-1"}, {Cmd: "command-2"}, - {Cmd: "command-3"}, + {Task: "task-1"}, }, } @@ -84,7 +84,7 @@ func TestPrintTaskCommandsIfPresent(t *testing.T) { assert.Contains(t, buffer.String(), "\ncommands:\n") assert.Contains(t, buffer.String(), "\n - command-1\n") assert.Contains(t, buffer.String(), "\n - command-2\n") - assert.Contains(t, buffer.String(), "\n - command-3\n") + assert.Contains(t, buffer.String(), "\n - Task: task-1\n") } func TestDoesNotPrintCommandIfMissing(t *testing.T) { From 5cfd9bbbbdd0c65a1e0814db25756fb341dc717d Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 17:25:03 +0100 Subject: [PATCH 55/83] refactoring --- internal/summary/summary.go | 3 ++- internal/summary/summary_test.go | 29 ++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index df864823..db5476cf 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -24,7 +24,8 @@ func printTaskCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { logger.Outf("") logger.Outf("commands:") for _, c := range cmds { - if c.Cmd != "" { + isCommand := c.Cmd != "" + if isCommand { logger.Outf(" - %s", c.Cmd) } else { logger.Outf(" - Task: %s", c.Task) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index b64e1c7f..6191cca6 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -123,19 +123,22 @@ func TestFullSummary(t *testing.T) { summary.Print(&l, task) + assert.Equal(t, expectedOutput(), buffer.String()) +} + +func expectedOutput() string { expected := `task: sample-task - -line1 -line2 -line3 - -dependencies: - - dependency - -commands: - - command -` - - assert.Equal(t, expected, buffer.String()) + + line1 + line2 + line3 + + dependencies: + - dependency + + commands: + - command + ` + return expected } From a9012ebfc5021b005a1b1693e73004c80d1a5c40 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 17:28:06 +0100 Subject: [PATCH 56/83] refactoring --- internal/summary/summary_test.go | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index 6191cca6..731ff693 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -26,10 +26,7 @@ func TestPrintsDependenciesIfPresent(t *testing.T) { summary.Print(&l, task) - assert.Contains(t, buffer.String(), "\ndependencies:\n") - assert.Contains(t, buffer.String(), "\n - dep1\n") - assert.Contains(t, buffer.String(), "\n - dep2\n") - assert.Contains(t, buffer.String(), "\n - dep3\n") + assert.Contains(t, buffer.String(), "\ndependencies:\n"+" - dep1\n"+" - dep2\n"+" - dep3\n") } func TestDoesNotPrintDependenciesIfMissing(t *testing.T) { @@ -127,18 +124,17 @@ func TestFullSummary(t *testing.T) { } func expectedOutput() string { - expected := - `task: sample-task - - line1 - line2 - line3 - - dependencies: - - dependency - - commands: - - command - ` + expected := `task: sample-task + +line1 +line2 +line3 + +dependencies: + - dependency + +commands: + - command +` return expected } From e252972c7ff6172c9aa6c788908938d19d3ad592 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 17:29:03 +0100 Subject: [PATCH 57/83] rename test --- internal/summary/summary_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index 731ff693..929501e1 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -100,7 +100,7 @@ func TestDoesNotPrintCommandIfMissing(t *testing.T) { assert.NotContains(t, buffer.String(), "commands") } -func TestFullSummary(t *testing.T) { +func TestLayout(t *testing.T) { buffer := &bytes.Buffer{} l := logger.Logger{ Stdout: buffer, From 845b88a1939eec0813089825c3c8378a0e8029e3 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 18:20:59 +0100 Subject: [PATCH 58/83] print only task name if summary --- internal/summary/summary.go | 38 +++++++++++++++++++++----------- internal/summary/summary_test.go | 25 +++++++++++++++++++++ 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index db5476cf..8d44ab19 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -6,11 +6,19 @@ import ( "strings" ) -func Print(Logger *logger.Logger, task *taskfile.Task) { - printTaskName(Logger, task) - printTaskSummary(task.Summary, Logger) - printTaskDependencies(task.Deps, Logger) - printTaskCommands(task.Cmds, Logger) +func Print(l *logger.Logger, t *taskfile.Task) { + printTaskName(l, t) + if hasSummary(t) { + printTaskSummary(l, t) + } else { + printTaskDescription(l, t) + } + printTaskDependencies(l, t) + printTaskCommands(l, t) +} + +func hasSummary(task *taskfile.Task) bool { + return task.Summary != "" } func printTaskName(Logger *logger.Logger, task *taskfile.Task) { @@ -18,12 +26,12 @@ func printTaskName(Logger *logger.Logger, task *taskfile.Task) { Logger.Outf("") } -func printTaskCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { - hasCommands := len(cmds) > 0 +func printTaskCommands(logger *logger.Logger, task *taskfile.Task) { + hasCommands := len(task.Cmds) > 0 if hasCommands { logger.Outf("") logger.Outf("commands:") - for _, c := range cmds { + for _, c := range task.Cmds { isCommand := c.Cmd != "" if isCommand { logger.Outf(" - %s", c.Cmd) @@ -34,20 +42,20 @@ func printTaskCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { } } -func printTaskDependencies(deps []*taskfile.Dep, logger *logger.Logger) { - hasDependencies := len(deps) > 0 +func printTaskDependencies(logger *logger.Logger, task *taskfile.Task) { + hasDependencies := len(task.Deps) > 0 if hasDependencies { logger.Outf("") logger.Outf("dependencies:") - for _, d := range deps { + for _, d := range task.Deps { logger.Outf(" - %s", d.Task) } } } -func printTaskSummary(description string, Logger *logger.Logger) { - lines := strings.Split(description, "\n") +func printTaskSummary(Logger *logger.Logger, task *taskfile.Task) { + lines := strings.Split(task.Summary, "\n") for i, line := range lines { notLastLine := i+1 < len(lines) if notLastLine || line != "" { @@ -55,3 +63,7 @@ func printTaskSummary(description string, Logger *logger.Logger) { } } } + +func printTaskDescription(Logger *logger.Logger, task *taskfile.Task) { + Logger.Outf(task.Desc) +} diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index 929501e1..1b4087be 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -138,3 +138,28 @@ commands: ` return expected } + +func TestPrintDescriptionAsFallback(t *testing.T) { + buffer := &bytes.Buffer{} + l := logger.Logger{ + Stdout: buffer, + Stderr: buffer, + Verbose: false, + } + taskWithoutSummary := &taskfile.Task{ + Desc: "description", + } + + taskWithSummary := &taskfile.Task{ + Desc: "description", + Summary: "summary", + } + + summary.Print(&l, taskWithoutSummary) + assert.Contains(t, buffer.String(), "description") + + buffer.Reset() + summary.Print(&l, taskWithSummary) + assert.NotContains(t, buffer.String(), "description") + +} From 3f8ee218492447b280927bba91fb47ba5da1c887 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 18:26:16 +0100 Subject: [PATCH 59/83] print error messsage if no summary or description present --- internal/summary/summary.go | 64 ++++++++++++++++++-------------- internal/summary/summary_test.go | 5 +++ 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index 8d44ab19..3e811869 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -10,8 +10,10 @@ func Print(l *logger.Logger, t *taskfile.Task) { printTaskName(l, t) if hasSummary(t) { printTaskSummary(l, t) - } else { + } else if hasDescription(t) { printTaskDescription(l, t) + } else { + printErrorNoDescriptionOrSummary(l) } printTaskDependencies(l, t) printTaskCommands(l, t) @@ -21,11 +23,45 @@ func hasSummary(task *taskfile.Task) bool { return task.Summary != "" } +func printTaskSummary(Logger *logger.Logger, task *taskfile.Task) { + lines := strings.Split(task.Summary, "\n") + for i, line := range lines { + notLastLine := i+1 < len(lines) + if notLastLine || line != "" { + Logger.Outf(line) + } + } +} + func printTaskName(Logger *logger.Logger, task *taskfile.Task) { Logger.Outf("task: " + task.Task) Logger.Outf("") } +func hasDescription(task *taskfile.Task) bool { + return task.Desc != "" +} + +func printTaskDescription(Logger *logger.Logger, task *taskfile.Task) { + Logger.Outf(task.Desc) +} + +func printErrorNoDescriptionOrSummary(l *logger.Logger) { + l.Outf("(task does not have description or summary)") +} + +func printTaskDependencies(logger *logger.Logger, task *taskfile.Task) { + hasDependencies := len(task.Deps) > 0 + if hasDependencies { + logger.Outf("") + logger.Outf("dependencies:") + + for _, d := range task.Deps { + logger.Outf(" - %s", d.Task) + } + } +} + func printTaskCommands(logger *logger.Logger, task *taskfile.Task) { hasCommands := len(task.Cmds) > 0 if hasCommands { @@ -41,29 +77,3 @@ func printTaskCommands(logger *logger.Logger, task *taskfile.Task) { } } } - -func printTaskDependencies(logger *logger.Logger, task *taskfile.Task) { - hasDependencies := len(task.Deps) > 0 - if hasDependencies { - logger.Outf("") - logger.Outf("dependencies:") - - for _, d := range task.Deps { - logger.Outf(" - %s", d.Task) - } - } -} - -func printTaskSummary(Logger *logger.Logger, task *taskfile.Task) { - lines := strings.Split(task.Summary, "\n") - for i, line := range lines { - notLastLine := i+1 < len(lines) - if notLastLine || line != "" { - Logger.Outf(line) - } - } -} - -func printTaskDescription(Logger *logger.Logger, task *taskfile.Task) { - Logger.Outf(task.Desc) -} diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index 1b4087be..d198ee26 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -154,6 +154,7 @@ func TestPrintDescriptionAsFallback(t *testing.T) { Desc: "description", Summary: "summary", } + taskWithoutSummaryOrDescription := &taskfile.Task{} summary.Print(&l, taskWithoutSummary) assert.Contains(t, buffer.String(), "description") @@ -162,4 +163,8 @@ func TestPrintDescriptionAsFallback(t *testing.T) { summary.Print(&l, taskWithSummary) assert.NotContains(t, buffer.String(), "description") + buffer.Reset() + summary.Print(&l, taskWithoutSummaryOrDescription) + assert.Contains(t, buffer.String(), "\n(task does not have description or summary)\n") + } From 3ca590b185c8ae0907275d991d8f99a6bd0ac5fb Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 19:02:44 +0100 Subject: [PATCH 60/83] display summary for tasks without summary/description --- docs/usage.md | 26 +++++++++++++++---- task.go | 12 +-------- task_test.go | 14 ---------- testdata/summary/Taskfile.yml | 17 ------------ ...ask-with-summary-containing-empty-line.txt | 8 ------ testdata/summary/task-without-commands.txt | 6 ----- 6 files changed, 22 insertions(+), 61 deletions(-) delete mode 100644 testdata/summary/task-with-summary-containing-empty-line.txt delete mode 100644 testdata/summary/task-without-commands.txt diff --git a/docs/usage.md b/docs/usage.md index 4f6d8aa0..0b1c505a 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -544,7 +544,7 @@ would print the following output: ## Detailed task description -Running `task --details task-name` will show a detailed description of a task if present. +Running `task --summary task-name` will show a summary of a task The following Taskfile: ```yaml @@ -552,23 +552,39 @@ version: '2' tasks: release: - details: | + deps: [build] + summary: | Release your project to github + It will build your project before starting the release it. Please make sure that you have set GITHUB_TOKEN before starting. cmds: - your-release-tool + build: + cmds: + - your-build-tool ``` -with running ``task --details release`` would print the following output: +with running ``task --summary release`` would print the following output: ``` +task: release + Release your project to github +It will build your project before starting the release it. Please make sure that you have set GITHUB_TOKEN before starting. -``` -Please note: *showing the detailed description will not execute the command* +dependencies: + - build + +commands: + - your-release-tool +``` +If a summary is missing, the description will be printed. +If the task does not have a summary or a description, a warning is printed. + +Please note: *showing the summary will not execute the command* ## Silent mode diff --git a/task.go b/task.go index b85c8762..2cc84cd7 100644 --- a/task.go +++ b/task.go @@ -66,7 +66,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { if e.Summary { firstTask := calls[0].Task - e.printTaskSummary(firstTask) + summary.Print(e.Logger, e.Taskfile.Tasks[firstTask]) return nil } @@ -82,16 +82,6 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { return nil } -func (e *Executor) printTaskSummary(task string) { - t := e.Taskfile.Tasks[task] - if t.Summary == "" { - e.Logger.Errf("task: There is no summary for task: %s", task) - return - } - - summary.Print(e.Logger, t) -} - // Setup setups Executor's internal state func (e *Executor) Setup() error { var err error diff --git a/task_test.go b/task_test.go index a3636826..392c40a8 100644 --- a/task_test.go +++ b/task_test.go @@ -569,26 +569,12 @@ func TestSummary(t *testing.T) { assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary"})) assert.Equal(t, readTestFixture(t, dir, "task-with-summary.txt"), buff.String()) - buff.Reset() - const nosummary = "task-without-summary" - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: nosummary})) - assert.Equal(t, "task: There is no summary for task: "+nosummary+"\n", buff.String()) - buff.Reset() const firstTask = "other-task-with-summary" const secondTask = "task-with-summary" assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: firstTask}, taskfile.Call{Task: secondTask})) assert.Contains(t, buff.String(), "summary of "+firstTask) assert.NotContains(t, buff.String(), "summary of "+secondTask) - - buff.Reset() - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary-containing-empty-line"})) - assert.Equal(t, readTestFixture(t, dir, "task-with-summary-containing-empty-line.txt"), buff.String()) - - buff.Reset() - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-without-commands"})) - assert.Equal(t, readTestFixture(t, dir, "task-without-commands.txt"), buff.String()) - } func readTestFixture(t *testing.T, dir string, file string) string { diff --git a/testdata/summary/Taskfile.yml b/testdata/summary/Taskfile.yml index cf07e9df..dc9b6204 100644 --- a/testdata/summary/Taskfile.yml +++ b/testdata/summary/Taskfile.yml @@ -13,28 +13,11 @@ tasks: - echo 'another command' - exit 0 - task-without-summary: - deps: [dependend-task-1] - cmds: - - echo 'task-without-summary was executed' - other-task-with-summary: summary: summary of other-task-with-summary cmds: - echo 'other-task-with-summary was executed' - task-with-summary-containing-empty-line: - summary: | - First line followed by empty line - - Last Line - cmds: - - exit 0 - - task-without-commands: - summary: summary - deps: [dependend-task-1] - dependend-task-1: cmds: - echo 'dependend-task-1 was executed' diff --git a/testdata/summary/task-with-summary-containing-empty-line.txt b/testdata/summary/task-with-summary-containing-empty-line.txt deleted file mode 100644 index 8eca5e86..00000000 --- a/testdata/summary/task-with-summary-containing-empty-line.txt +++ /dev/null @@ -1,8 +0,0 @@ -task: task-with-summary-containing-empty-line - -First line followed by empty line - -Last Line - -commands: - - exit 0 diff --git a/testdata/summary/task-without-commands.txt b/testdata/summary/task-without-commands.txt deleted file mode 100644 index c7c5b024..00000000 --- a/testdata/summary/task-without-commands.txt +++ /dev/null @@ -1,6 +0,0 @@ -task: task-without-commands - -summary - -dependencies: - - dependend-task-1 From c1586082553acbe9fb608fcea8666763c4009d71 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 19:10:44 +0100 Subject: [PATCH 61/83] fix error in documentation --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 0b1c505a..de93df3e 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -542,7 +542,7 @@ would print the following output: * test: Run all the go tests. ``` -## Detailed task description +## Display summary of task Running `task --summary task-name` will show a summary of a task The following Taskfile: From 2a1571a99e65ac3e7bbc102ea2ae129cdd87dfad Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 19:14:15 +0100 Subject: [PATCH 62/83] refactoring --- internal/summary/summary.go | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index 3e811869..132f5710 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -13,66 +13,66 @@ func Print(l *logger.Logger, t *taskfile.Task) { } else if hasDescription(t) { printTaskDescription(l, t) } else { - printErrorNoDescriptionOrSummary(l) + printNoDescriptionOrSummary(l) } printTaskDependencies(l, t) printTaskCommands(l, t) } -func hasSummary(task *taskfile.Task) bool { - return task.Summary != "" +func hasSummary(t *taskfile.Task) bool { + return t.Summary != "" } -func printTaskSummary(Logger *logger.Logger, task *taskfile.Task) { - lines := strings.Split(task.Summary, "\n") +func printTaskSummary(l *logger.Logger, t *taskfile.Task) { + lines := strings.Split(t.Summary, "\n") for i, line := range lines { notLastLine := i+1 < len(lines) if notLastLine || line != "" { - Logger.Outf(line) + l.Outf(line) } } } -func printTaskName(Logger *logger.Logger, task *taskfile.Task) { - Logger.Outf("task: " + task.Task) - Logger.Outf("") +func printTaskName(l *logger.Logger, t *taskfile.Task) { + l.Outf("task: " + t.Task) + l.Outf("") } -func hasDescription(task *taskfile.Task) bool { - return task.Desc != "" +func hasDescription(t *taskfile.Task) bool { + return t.Desc != "" } -func printTaskDescription(Logger *logger.Logger, task *taskfile.Task) { - Logger.Outf(task.Desc) +func printTaskDescription(l *logger.Logger, t *taskfile.Task) { + l.Outf(t.Desc) } -func printErrorNoDescriptionOrSummary(l *logger.Logger) { +func printNoDescriptionOrSummary(l *logger.Logger) { l.Outf("(task does not have description or summary)") } -func printTaskDependencies(logger *logger.Logger, task *taskfile.Task) { - hasDependencies := len(task.Deps) > 0 +func printTaskDependencies(l *logger.Logger, t *taskfile.Task) { + hasDependencies := len(t.Deps) > 0 if hasDependencies { - logger.Outf("") - logger.Outf("dependencies:") + l.Outf("") + l.Outf("dependencies:") - for _, d := range task.Deps { - logger.Outf(" - %s", d.Task) + for _, d := range t.Deps { + l.Outf(" - %s", d.Task) } } } -func printTaskCommands(logger *logger.Logger, task *taskfile.Task) { - hasCommands := len(task.Cmds) > 0 +func printTaskCommands(l *logger.Logger, t *taskfile.Task) { + hasCommands := len(t.Cmds) > 0 if hasCommands { - logger.Outf("") - logger.Outf("commands:") - for _, c := range task.Cmds { + l.Outf("") + l.Outf("commands:") + for _, c := range t.Cmds { isCommand := c.Cmd != "" if isCommand { - logger.Outf(" - %s", c.Cmd) + l.Outf(" - %s", c.Cmd) } else { - logger.Outf(" - Task: %s", c.Task) + l.Outf(" - Task: %s", c.Task) } } } From c2e0f8c81fc7b0f488a30b705aaab728cdacb87f Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 3 Mar 2019 18:56:42 +0100 Subject: [PATCH 63/83] Update docs/usage.md Co-Authored-By: jaedle <32975714+jaedle@users.noreply.github.com> --- docs/usage.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/usage.md b/docs/usage.md index de93df3e..5dac4736 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -560,6 +560,7 @@ tasks: Please make sure that you have set GITHUB_TOKEN before starting. cmds: - your-release-tool + build: cmds: - your-build-tool From 9dea1e7f3e2555ac1c86d5d6255eb08e0bce243b Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 3 Mar 2019 19:43:23 +0100 Subject: [PATCH 64/83] Update docs/usage.md Co-Authored-By: jaedle <32975714+jaedle@users.noreply.github.com> --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 5dac4736..fd597ec9 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -585,7 +585,7 @@ commands: If a summary is missing, the description will be printed. If the task does not have a summary or a description, a warning is printed. -Please note: *showing the summary will not execute the command* +Please note: *showing the summary will not execute the command*. ## Silent mode From f5f0e0c376943b175b86a29fe44017b10eec0dff Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 3 Mar 2019 19:43:57 +0100 Subject: [PATCH 65/83] Update internal/summary/summary.go Co-Authored-By: jaedle <32975714+jaedle@users.noreply.github.com> --- internal/summary/summary.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index 132f5710..13794723 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -34,7 +34,7 @@ func printTaskSummary(l *logger.Logger, t *taskfile.Task) { } func printTaskName(l *logger.Logger, t *taskfile.Task) { - l.Outf("task: " + t.Task) + l.Outf("task: %s", t.Task) l.Outf("") } From 26ce4e6886d95573dfd9d632830c7806ad9d54ff Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 3 Mar 2019 19:44:14 +0100 Subject: [PATCH 66/83] Update testdata/summary/Taskfile.yml Co-Authored-By: jaedle <32975714+jaedle@users.noreply.github.com> --- testdata/summary/Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/summary/Taskfile.yml b/testdata/summary/Taskfile.yml index dc9b6204..9f8a4d2f 100644 --- a/testdata/summary/Taskfile.yml +++ b/testdata/summary/Taskfile.yml @@ -3,7 +3,7 @@ version: 2 tasks: task-with-summary: - deps: [dependend-task-1,dependend-task-2] + deps: [dependend-task-1, dependend-task-2] summary: | summary of task-with-summary - line 1 line 2 From 5bca3cfd71cdd17f23969daa096366bfed254063 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 3 Mar 2019 19:44:27 +0100 Subject: [PATCH 67/83] Update testdata/summary/Taskfile.yml Co-Authored-By: jaedle <32975714+jaedle@users.noreply.github.com> --- testdata/summary/Taskfile.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/testdata/summary/Taskfile.yml b/testdata/summary/Taskfile.yml index 9f8a4d2f..ae8ad7ed 100644 --- a/testdata/summary/Taskfile.yml +++ b/testdata/summary/Taskfile.yml @@ -1,7 +1,6 @@ version: 2 tasks: - task-with-summary: deps: [dependend-task-1, dependend-task-2] summary: | From f945cf2343d0516813642ba1871c00048b17d839 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 3 Mar 2019 19:45:00 +0100 Subject: [PATCH 68/83] Update internal/summary/summary_test.go Co-Authored-By: jaedle <32975714+jaedle@users.noreply.github.com> --- internal/summary/summary_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index d198ee26..ad365235 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -26,7 +26,7 @@ func TestPrintsDependenciesIfPresent(t *testing.T) { summary.Print(&l, task) - assert.Contains(t, buffer.String(), "\ndependencies:\n"+" - dep1\n"+" - dep2\n"+" - dep3\n") + assert.Contains(t, buffer.String(), "\ndependencies:\n - dep1\n - dep2\n - dep3\n") } func TestDoesNotPrintDependenciesIfMissing(t *testing.T) { From 34f6da86c3595d8f11a893725551c289f34d4e16 Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:03:28 +0100 Subject: [PATCH 69/83] rearrange imports --- internal/summary/summary.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index 13794723..f6b56ac7 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -1,9 +1,10 @@ package summary import ( + "strings" + "github.com/go-task/task/v2/internal/logger" "github.com/go-task/task/v2/internal/taskfile" - "strings" ) func Print(l *logger.Logger, t *taskfile.Task) { From 7e7e1bccba9e3ca8890ee1019597f3765b600dd6 Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:04:31 +0100 Subject: [PATCH 70/83] rearrange imports --- internal/summary/summary_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index ad365235..dd412b15 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -2,11 +2,13 @@ package summary_test import ( "bytes" + "testing" + "github.com/go-task/task/v2/internal/logger" "github.com/go-task/task/v2/internal/summary" "github.com/go-task/task/v2/internal/taskfile" + "github.com/stretchr/testify/assert" - "testing" ) func TestPrintsDependenciesIfPresent(t *testing.T) { From 93bfd578563429b87e5e0dc19744c9fd5ebb2861 Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:09:58 +0100 Subject: [PATCH 71/83] print summary for multiple tasks --- task.go | 5 +++-- task_test.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/task.go b/task.go index 2cc84cd7..798c6bfe 100644 --- a/task.go +++ b/task.go @@ -65,8 +65,9 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } if e.Summary { - firstTask := calls[0].Task - summary.Print(e.Logger, e.Taskfile.Tasks[firstTask]) + for _, call := range calls { + summary.Print(e.Logger, e.Taskfile.Tasks[call.Task]) + } return nil } diff --git a/task_test.go b/task_test.go index 392c40a8..4aa6db0d 100644 --- a/task_test.go +++ b/task_test.go @@ -574,7 +574,7 @@ func TestSummary(t *testing.T) { const secondTask = "task-with-summary" assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: firstTask}, taskfile.Call{Task: secondTask})) assert.Contains(t, buff.String(), "summary of "+firstTask) - assert.NotContains(t, buff.String(), "summary of "+secondTask) + assert.Contains(t, buff.String(), "summary of "+secondTask) } func readTestFixture(t *testing.T, dir string, file string) string { From 808542bed0d0a0e2b996731601fae91798255bba Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:13:13 +0100 Subject: [PATCH 72/83] remove unnecassry test for multiple summaries --- task_test.go | 9 +-------- testdata/summary/task-with-summary.txt | 6 ++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/task_test.go b/task_test.go index 4aa6db0d..e2278dc5 100644 --- a/task_test.go +++ b/task_test.go @@ -566,15 +566,8 @@ func TestSummary(t *testing.T) { Silent: true, } assert.NoError(t, e.Setup()) - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary"})) + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary"}, taskfile.Call{Task: "other-task-with-summary"})) assert.Equal(t, readTestFixture(t, dir, "task-with-summary.txt"), buff.String()) - - buff.Reset() - const firstTask = "other-task-with-summary" - const secondTask = "task-with-summary" - assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: firstTask}, taskfile.Call{Task: secondTask})) - assert.Contains(t, buff.String(), "summary of "+firstTask) - assert.Contains(t, buff.String(), "summary of "+secondTask) } func readTestFixture(t *testing.T, dir string, file string) string { diff --git a/testdata/summary/task-with-summary.txt b/testdata/summary/task-with-summary.txt index c01eba06..0c10fba2 100644 --- a/testdata/summary/task-with-summary.txt +++ b/testdata/summary/task-with-summary.txt @@ -12,3 +12,9 @@ commands: - echo 'task-with-summary was executed' - echo 'another command' - exit 0 +task: other-task-with-summary + +summary of other-task-with-summary + +commands: + - echo 'other-task-with-summary was executed' From 23c4adcef6149d5d9451d0cec854842e0933a5df Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:15:40 +0100 Subject: [PATCH 73/83] add spacing for tasks --- task.go | 6 +++++- testdata/summary/task-with-summary.txt | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/task.go b/task.go index 798c6bfe..51a5640d 100644 --- a/task.go +++ b/task.go @@ -65,7 +65,11 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } if e.Summary { - for _, call := range calls { + for i, call := range calls { + if i > 0 { + e.Logger.Outf("") + e.Logger.Outf("") + } summary.Print(e.Logger, e.Taskfile.Tasks[call.Task]) } return nil diff --git a/testdata/summary/task-with-summary.txt b/testdata/summary/task-with-summary.txt index 0c10fba2..80711300 100644 --- a/testdata/summary/task-with-summary.txt +++ b/testdata/summary/task-with-summary.txt @@ -12,6 +12,8 @@ commands: - echo 'task-with-summary was executed' - echo 'another command' - exit 0 + + task: other-task-with-summary summary of other-task-with-summary From c7f17b5319c51d1367b4df5d61fa740d90323d6d Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:25:42 +0100 Subject: [PATCH 74/83] refactoring --- internal/summary/summary.go | 10 ++++++++++ task.go | 8 +------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index f6b56ac7..dc1b9aa8 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -7,6 +7,16 @@ import ( "github.com/go-task/task/v2/internal/taskfile" ) +func PrintAll(l *logger.Logger, t *taskfile.Taskfile, c []taskfile.Call) { + for i, call := range c { + if i > 0 { + l.Outf("") + l.Outf("") + } + Print(l, t.Tasks[call.Task]) + } +} + func Print(l *logger.Logger, t *taskfile.Task) { printTaskName(l, t) if hasSummary(t) { diff --git a/task.go b/task.go index 51a5640d..738c075f 100644 --- a/task.go +++ b/task.go @@ -65,13 +65,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } if e.Summary { - for i, call := range calls { - if i > 0 { - e.Logger.Outf("") - e.Logger.Outf("") - } - summary.Print(e.Logger, e.Taskfile.Tasks[call.Task]) - } + summary.PrintAll(e.Logger, e.Taskfile, calls) return nil } From f66edbad508db859ae5facbd197c4c8938ae2a9f Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:27:10 +0100 Subject: [PATCH 75/83] refactoring --- internal/summary/summary.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index dc1b9aa8..d5abb4e3 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -9,14 +9,21 @@ import ( func PrintAll(l *logger.Logger, t *taskfile.Taskfile, c []taskfile.Call) { for i, call := range c { - if i > 0 { - l.Outf("") - l.Outf("") - } + printSpaceBetweenSummaries(i, l) Print(l, t.Tasks[call.Task]) } } +func printSpaceBetweenSummaries(i int, l *logger.Logger) { + spaceRequired := i > 0 + if !spaceRequired { + return + } + + l.Outf("") + l.Outf("") +} + func Print(l *logger.Logger, t *taskfile.Task) { printTaskName(l, t) if hasSummary(t) { From 8eadfc1bf68336ec2815b50db64bd94e20abedb6 Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:28:11 +0100 Subject: [PATCH 76/83] refactoring --- internal/summary/summary.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index d5abb4e3..af1896ea 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -81,17 +81,19 @@ func printTaskDependencies(l *logger.Logger, t *taskfile.Task) { } func printTaskCommands(l *logger.Logger, t *taskfile.Task) { - hasCommands := len(t.Cmds) > 0 - if hasCommands { - l.Outf("") - l.Outf("commands:") - for _, c := range t.Cmds { - isCommand := c.Cmd != "" - if isCommand { - l.Outf(" - %s", c.Cmd) - } else { - l.Outf(" - Task: %s", c.Task) - } + noCommands := len(t.Cmds) == 0 + if noCommands { + return + } + + l.Outf("") + l.Outf("commands:") + for _, c := range t.Cmds { + isCommand := c.Cmd != "" + if isCommand { + l.Outf(" - %s", c.Cmd) + } else { + l.Outf(" - Task: %s", c.Task) } } } From 4fd82ab222977a3eb0450682c4e93e43e592c2a8 Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:28:26 +0100 Subject: [PATCH 77/83] refactoring --- internal/summary/summary.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index af1896ea..93bd87b0 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -81,8 +81,7 @@ func printTaskDependencies(l *logger.Logger, t *taskfile.Task) { } func printTaskCommands(l *logger.Logger, t *taskfile.Task) { - noCommands := len(t.Cmds) == 0 - if noCommands { + if len(t.Cmds) == 0 { return } From 1025c2e3a1ccc27a4c95ce79bbfb8de1a07a04bc Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:46:02 +0100 Subject: [PATCH 78/83] add unit test for spacing between summaries --- internal/summary/summary.go | 15 +++--- internal/summary/summary_test.go | 79 +++++++++++++++++--------------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index 93bd87b0..05933ebe 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -69,14 +69,15 @@ func printNoDescriptionOrSummary(l *logger.Logger) { } func printTaskDependencies(l *logger.Logger, t *taskfile.Task) { - hasDependencies := len(t.Deps) > 0 - if hasDependencies { - l.Outf("") - l.Outf("dependencies:") + if len(t.Deps) == 0 { + return + } - for _, d := range t.Deps { - l.Outf(" - %s", d.Task) - } + l.Outf("") + l.Outf("dependencies:") + + for _, d := range t.Deps { + l.Outf(" - %s", d.Task) } } diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index dd412b15..8c2ae487 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -2,6 +2,7 @@ package summary_test import ( "bytes" + "strings" "testing" "github.com/go-task/task/v2/internal/logger" @@ -12,12 +13,7 @@ import ( ) func TestPrintsDependenciesIfPresent(t *testing.T) { - buffer := &bytes.Buffer{} - l := logger.Logger{ - Stdout: buffer, - Stderr: buffer, - Verbose: false, - } + buffer, l := createDummyLogger() task := &taskfile.Task{ Deps: []*taskfile.Dep{ {Task: "dep1"}, @@ -31,13 +27,18 @@ func TestPrintsDependenciesIfPresent(t *testing.T) { assert.Contains(t, buffer.String(), "\ndependencies:\n - dep1\n - dep2\n - dep3\n") } -func TestDoesNotPrintDependenciesIfMissing(t *testing.T) { +func createDummyLogger() (*bytes.Buffer, logger.Logger) { buffer := &bytes.Buffer{} l := logger.Logger{ - Stdout: buffer, Stderr: buffer, + Stdout: buffer, Verbose: false, } + return buffer, l +} + +func TestDoesNotPrintDependenciesIfMissing(t *testing.T) { + buffer, l := createDummyLogger() task := &taskfile.Task{ Deps: []*taskfile.Dep{}, } @@ -48,12 +49,7 @@ func TestDoesNotPrintDependenciesIfMissing(t *testing.T) { } func TestPrintTaskName(t *testing.T) { - buffer := &bytes.Buffer{} - l := logger.Logger{ - Stdout: buffer, - Stderr: buffer, - Verbose: false, - } + buffer, l := createDummyLogger() task := &taskfile.Task{ Task: "my-task-name", } @@ -64,12 +60,7 @@ func TestPrintTaskName(t *testing.T) { } func TestPrintTaskCommandsIfPresent(t *testing.T) { - buffer := &bytes.Buffer{} - l := logger.Logger{ - Stdout: buffer, - Stderr: buffer, - Verbose: false, - } + buffer, l := createDummyLogger() task := &taskfile.Task{ Cmds: []*taskfile.Cmd{ {Cmd: "command-1"}, @@ -87,12 +78,7 @@ func TestPrintTaskCommandsIfPresent(t *testing.T) { } func TestDoesNotPrintCommandIfMissing(t *testing.T) { - buffer := &bytes.Buffer{} - l := logger.Logger{ - Stdout: buffer, - Stderr: buffer, - Verbose: false, - } + buffer, l := createDummyLogger() task := &taskfile.Task{ Cmds: []*taskfile.Cmd{}, } @@ -103,12 +89,7 @@ func TestDoesNotPrintCommandIfMissing(t *testing.T) { } func TestLayout(t *testing.T) { - buffer := &bytes.Buffer{} - l := logger.Logger{ - Stdout: buffer, - Stderr: buffer, - Verbose: false, - } + buffer, l := createDummyLogger() task := &taskfile.Task{ Task: "sample-task", Summary: "line1\nline2\nline3\n", @@ -142,12 +123,7 @@ commands: } func TestPrintDescriptionAsFallback(t *testing.T) { - buffer := &bytes.Buffer{} - l := logger.Logger{ - Stdout: buffer, - Stderr: buffer, - Verbose: false, - } + buffer, l := createDummyLogger() taskWithoutSummary := &taskfile.Task{ Desc: "description", } @@ -159,14 +135,41 @@ func TestPrintDescriptionAsFallback(t *testing.T) { taskWithoutSummaryOrDescription := &taskfile.Task{} summary.Print(&l, taskWithoutSummary) + assert.Contains(t, buffer.String(), "description") buffer.Reset() summary.Print(&l, taskWithSummary) + assert.NotContains(t, buffer.String(), "description") buffer.Reset() summary.Print(&l, taskWithoutSummaryOrDescription) + assert.Contains(t, buffer.String(), "\n(task does not have description or summary)\n") } + +func TestPrintAllWithSpaces(t *testing.T) { + buffer, l := createDummyLogger() + + t1 := &taskfile.Task{Task: "t1"} + t2 := &taskfile.Task{Task: "t2"} + t3 := &taskfile.Task{Task: "t3"} + + tasks := make(taskfile.Tasks, 3) + tasks["t1"] = t1 + tasks["t2"] = t2 + tasks["t3"] = t3 + + tf := &taskfile.Taskfile{ + Tasks: tasks, + } + + summary.PrintAll(&l, tf, []taskfile.Call{{Task: "t1"}, {Task: "t2"}, {Task: "t3"}}) + + assert.True(t, strings.HasPrefix(buffer.String(), "task: t1")) + assert.Contains(t, buffer.String(), "\n(task does not have description or summary)\n\n\ntask: t2") + assert.Contains(t, buffer.String(), "\n(task does not have description or summary)\n\n\ntask: t3") + +} From 1d783bf6c70232084c79be820db9718ee87df936 Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:46:53 +0100 Subject: [PATCH 79/83] refactoring --- internal/summary/summary_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index 8c2ae487..c3122fb3 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -162,11 +162,9 @@ func TestPrintAllWithSpaces(t *testing.T) { tasks["t2"] = t2 tasks["t3"] = t3 - tf := &taskfile.Taskfile{ - Tasks: tasks, - } - - summary.PrintAll(&l, tf, []taskfile.Call{{Task: "t1"}, {Task: "t2"}, {Task: "t3"}}) + summary.PrintAll(&l, + &taskfile.Taskfile{Tasks: tasks}, + []taskfile.Call{{Task: "t1"}, {Task: "t2"}, {Task: "t3"}}) assert.True(t, strings.HasPrefix(buffer.String(), "task: t1")) assert.Contains(t, buffer.String(), "\n(task does not have description or summary)\n\n\ntask: t2") From b7564080bcf2e6edaffd9563c5044be70ec76802 Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:48:26 +0100 Subject: [PATCH 80/83] add space between tasks --- testdata/summary/Taskfile.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/testdata/summary/Taskfile.yml b/testdata/summary/Taskfile.yml index ae8ad7ed..5df3ef01 100644 --- a/testdata/summary/Taskfile.yml +++ b/testdata/summary/Taskfile.yml @@ -20,6 +20,7 @@ tasks: dependend-task-1: cmds: - echo 'dependend-task-1 was executed' + dependend-task-2: cmds: - echo 'dependend-task-2 was executed' From db90e87d109f56200e98c898ae9c940bdb521019 Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 12:53:06 +0100 Subject: [PATCH 81/83] rearrange imports --- task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task.go b/task.go index 738c075f..d7ba3fd7 100644 --- a/task.go +++ b/task.go @@ -3,7 +3,6 @@ package task import ( "context" "fmt" - "github.com/go-task/task/v2/internal/summary" "io" "os" "sync/atomic" @@ -14,6 +13,7 @@ import ( "github.com/go-task/task/v2/internal/execext" "github.com/go-task/task/v2/internal/logger" "github.com/go-task/task/v2/internal/output" + "github.com/go-task/task/v2/internal/summary" "github.com/go-task/task/v2/internal/taskfile" "github.com/go-task/task/v2/internal/taskfile/read" "github.com/go-task/task/v2/internal/taskfile/version" From 9cfac1642a6b2932cd930a0a47921791919c885e Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 13:03:13 +0100 Subject: [PATCH 82/83] rename method for summary/summaries --- internal/summary/summary.go | 10 +++++----- internal/summary/summary_test.go | 20 ++++++++++---------- task.go | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index 05933ebe..3dbfdf22 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -7,14 +7,14 @@ import ( "github.com/go-task/task/v2/internal/taskfile" ) -func PrintAll(l *logger.Logger, t *taskfile.Taskfile, c []taskfile.Call) { +func PrintTasks(l *logger.Logger, t *taskfile.Taskfile, c []taskfile.Call) { for i, call := range c { - printSpaceBetweenSummaries(i, l) - Print(l, t.Tasks[call.Task]) + printSpaceBetweenSummaries(l, i) + PrintTask(l, t.Tasks[call.Task]) } } -func printSpaceBetweenSummaries(i int, l *logger.Logger) { +func printSpaceBetweenSummaries(l *logger.Logger, i int) { spaceRequired := i > 0 if !spaceRequired { return @@ -24,7 +24,7 @@ func printSpaceBetweenSummaries(i int, l *logger.Logger) { l.Outf("") } -func Print(l *logger.Logger, t *taskfile.Task) { +func PrintTask(l *logger.Logger, t *taskfile.Task) { printTaskName(l, t) if hasSummary(t) { printTaskSummary(l, t) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index c3122fb3..95029efc 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -22,7 +22,7 @@ func TestPrintsDependenciesIfPresent(t *testing.T) { }, } - summary.Print(&l, task) + summary.PrintTask(&l, task) assert.Contains(t, buffer.String(), "\ndependencies:\n - dep1\n - dep2\n - dep3\n") } @@ -43,7 +43,7 @@ func TestDoesNotPrintDependenciesIfMissing(t *testing.T) { Deps: []*taskfile.Dep{}, } - summary.Print(&l, task) + summary.PrintTask(&l, task) assert.NotContains(t, buffer.String(), "dependencies:") } @@ -54,7 +54,7 @@ func TestPrintTaskName(t *testing.T) { Task: "my-task-name", } - summary.Print(&l, task) + summary.PrintTask(&l, task) assert.Contains(t, buffer.String(), "task: my-task-name\n") } @@ -69,7 +69,7 @@ func TestPrintTaskCommandsIfPresent(t *testing.T) { }, } - summary.Print(&l, task) + summary.PrintTask(&l, task) assert.Contains(t, buffer.String(), "\ncommands:\n") assert.Contains(t, buffer.String(), "\n - command-1\n") @@ -83,7 +83,7 @@ func TestDoesNotPrintCommandIfMissing(t *testing.T) { Cmds: []*taskfile.Cmd{}, } - summary.Print(&l, task) + summary.PrintTask(&l, task) assert.NotContains(t, buffer.String(), "commands") } @@ -101,7 +101,7 @@ func TestLayout(t *testing.T) { }, } - summary.Print(&l, task) + summary.PrintTask(&l, task) assert.Equal(t, expectedOutput(), buffer.String()) } @@ -134,17 +134,17 @@ func TestPrintDescriptionAsFallback(t *testing.T) { } taskWithoutSummaryOrDescription := &taskfile.Task{} - summary.Print(&l, taskWithoutSummary) + summary.PrintTask(&l, taskWithoutSummary) assert.Contains(t, buffer.String(), "description") buffer.Reset() - summary.Print(&l, taskWithSummary) + summary.PrintTask(&l, taskWithSummary) assert.NotContains(t, buffer.String(), "description") buffer.Reset() - summary.Print(&l, taskWithoutSummaryOrDescription) + summary.PrintTask(&l, taskWithoutSummaryOrDescription) assert.Contains(t, buffer.String(), "\n(task does not have description or summary)\n") @@ -162,7 +162,7 @@ func TestPrintAllWithSpaces(t *testing.T) { tasks["t2"] = t2 tasks["t3"] = t3 - summary.PrintAll(&l, + summary.PrintTasks(&l, &taskfile.Taskfile{Tasks: tasks}, []taskfile.Call{{Task: "t1"}, {Task: "t2"}, {Task: "t3"}}) diff --git a/task.go b/task.go index d7ba3fd7..f890cb5e 100644 --- a/task.go +++ b/task.go @@ -65,7 +65,7 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } if e.Summary { - summary.PrintAll(e.Logger, e.Taskfile, calls) + summary.PrintTasks(e.Logger, e.Taskfile, calls) return nil } From 360da29e1fe7b5a70e5f24dc046d97e6259ef515 Mon Sep 17 00:00:00 2001 From: jaedle Date: Mon, 4 Mar 2019 13:04:04 +0100 Subject: [PATCH 83/83] refactoring --- internal/summary/summary.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index 3dbfdf22..655ec76c 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -26,6 +26,12 @@ func printSpaceBetweenSummaries(l *logger.Logger, i int) { func PrintTask(l *logger.Logger, t *taskfile.Task) { printTaskName(l, t) + printTaskDescribingText(t, l) + printTaskDependencies(l, t) + printTaskCommands(l, t) +} + +func printTaskDescribingText(t *taskfile.Task, l *logger.Logger) { if hasSummary(t) { printTaskSummary(l, t) } else if hasDescription(t) { @@ -33,8 +39,6 @@ func PrintTask(l *logger.Logger, t *taskfile.Task) { } else { printNoDescriptionOrSummary(l) } - printTaskDependencies(l, t) - printTaskCommands(l, t) } func hasSummary(t *taskfile.Task) bool {