diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 6adf4e27..f0f58242 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,2 @@ open_collective: task +patreon: andreynering diff --git a/CHANGELOG.md b/CHANGELOG.md index 214637bb..f6ee94b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ - Add `--parallel` flag (alias `-p`) to run tasks given by the command line in parallel ([#266](https://github.com/go-task/task/pull/266)). +- Fixed bug where calling the `task` CLI only informing global vars would not + execute the `default` task. ## v2.7.1 - 2019-11-10 diff --git a/cmd/task/task.go b/cmd/task/task.go index 295526c0..d99db44d 100644 --- a/cmd/task/task.go +++ b/cmd/task/task.go @@ -139,13 +139,7 @@ func main() { return } - arguments := pflag.Args() - if len(arguments) == 0 { - e.Logger.Errf(logger.Yellow, "task: No argument given, trying default task") - arguments = []string{"default"} - } - - calls, globals := args.Parse(arguments...) + calls, globals := args.Parse(pflag.Args()...) for name, value := range globals { e.Taskfile.Vars[name] = value } diff --git a/internal/args/args.go b/internal/args/args.go index 0993e549..acea9c29 100644 --- a/internal/args/args.go +++ b/internal/args/args.go @@ -34,6 +34,10 @@ func Parse(args ...string) ([]taskfile.Call, taskfile.Vars) { } } + if len(calls) == 0 { + calls = append(calls, taskfile.Call{Task: "default"}) + } + return calls, globals } diff --git a/internal/args/args_test.go b/internal/args/args_test.go index 137c23e3..8dc96e4c 100644 --- a/internal/args/args_test.go +++ b/internal/args/args_test.go @@ -64,6 +64,28 @@ func TestArgs(t *testing.T) { "FOO": {Static: "bar"}, }, }, + { + Args: nil, + ExpectedCalls: []taskfile.Call{ + {Task: "default"}, + }, + }, + { + Args: []string{}, + ExpectedCalls: []taskfile.Call{ + {Task: "default"}, + }, + }, + { + Args: []string{"FOO=bar", "BAR=baz"}, + ExpectedCalls: []taskfile.Call{ + {Task: "default"}, + }, + ExpectedGlobals: taskfile.Vars{ + "FOO": {Static: "bar"}, + "BAR": {Static: "baz"}, + }, + }, } for i, test := range tests {