go-task / task

A task runner / simpler Make alternative written in Go
https://taskfile.dev
MIT License
11.35k stars 612 forks source link

Included and aliased Taskfiles don't play well with wildcards #1900

Open JackoCoolio opened 2 hours ago

JackoCoolio commented 2 hours ago

Including a Taskfile with wildcard tasks and aliasing it doesn't work.

Taskfile.yml:

version: '3'

includes:
  included:
    taskfile: Taskfile2.yml
    aliases: [inc]

tasks:
  foo-*:
    cmds:
      - "echo bar: {{index .MATCH 0}}"
    aliases: [f]

Taskfile2.yml

version: '3'

tasks:
  bar-*:
    cmds:
      - "echo bar: {{index .MATCH 0}}"

Output of task --list-all:

task: Available tasks for this project:
* foo-*:                      (aliases: f)
* included:bar-*:             (aliases: inc:bar-*)

That's pretty misleading, though, because trying some of the implied commands results in:

# f is a wildcard task, so it should take parameters
$ task f-hello
task: Task "f-hello" does not exist

# okay, let's just do what it says in "(aliases: f)"
$ task f
template: :1:12: executing "" at <index .MATCH 0>: error calling index: index of untyped nil

# that was even worse; what about bar in our included Taskfile?
$ task inc:bar-hello
task: Task "inc:bar-hello" does not exist
JackoCoolio commented 2 hours ago

I'm working on a fix for this, but figured I'd add an issue in the meantime :)