Skip to content

Support wildcards in task aliases #1900

@JackoCoolio

Description

@JackoCoolio

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
  • Task version: 3.38.0
  • Operating system: x86_64-pc-linux-gnu
  • Experiments enabled: N/A

Activity

JackoCoolio

JackoCoolio commented on Nov 2, 2024

@JackoCoolio
Author

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

changed the title [-]Included and aliased Taskfiles don't play well with wildcards[/-] [+]Support wildcards in task aliases[/+] on Jan 2, 2025
JacobPotter

JacobPotter commented on May 2, 2025

@JacobPotter

Hi, is there any update here? I am running into this issue as well.

linked a pull request that will close this issue on May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @JacobPotter@pd93@JackoCoolio@task-bot

      Issue actions

        Support wildcards in task aliases · Issue #1900 · go-task/task