Skip to content

Support named "wildcard" arguments in tasks #2480

@deepbrook

Description

@deepbrook

Description

When declaring wildcard arguments, the resulting held of the task isn't very helpful, and using multiple wild card arguments is hard to parse:

echo Taskfile.yaml
version: 3
tasks:
  hello:*:*:
  desc: Say hello to someone, using their first and last name!
    cmds:
      - cmd: echo Hello,{{ index .MATCH 0 }} {{ index .MATCH 1 }}!
❯ task --list
task: Available tasks for this project:
* hello:*:*:       Say hello to someone, using their first and last name!

Being able to name the arguments in the task name and populating a respectively named variable available for templating would be much more pleasant:

echo Taskfile.yaml
version: 3
tasks:
  hello:<first_name>:<last_name>:
  desc: Say hello to someone, using their first and last name!
    cmds:
      - cmd: echo Hello,{{ .first_name }} {{ .last_name }}!
❯ task --list
task: Available tasks for this project:
* hello:<first_name>:<last_name>:       Say hello to someone, using their first and last name!
❯ task hello:peter:parker
Hello, Peter Parker!

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: needs triageWaiting to be triaged by a maintainer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions