Skip to content

Conversation

pd93
Copy link
Member

@pd93 pd93 commented Mar 13, 2025

Fixes #2072

As discussed in #2072 and #1489 (comment), this PR allows calls to match multiple tasks when using wildcards. For example, given the following Taskfile:

version: 3 tasks: start:*:*: vars: SERVICE: "{{index .MATCH 0}}" REPLICAS: "{{index .MATCH 1}}" cmds: - echo "Starting {{.SERVICE}} with {{.REPLICAS}} replicas" start:*: vars: SERVICE: "{{index .MATCH 0}}" cmds: - echo "Starting {{.SERVICE}}" 

Currently, if you run task start:foo:1, you will get an error:

task: Found multiple tasks (start:*:*, start:*) that match "start:foo:1" 

However, after this change you will see

Starting foo with 1 replicas 

and if you run task start:foo, you will get

Starting foo 

Worth noting that the order is important. If you swap the tasks around, then you will be unable to call start:*:*. This is because if multiple tasks match, Task will use the task that is listed first in the Taskfile. In general, it is recommended to write more specific tasks (i.e. ones with more parameters) first.

@pd93 pd93 requested review from andreynering and vmaerten March 13, 2025 01:20
Copy link
Member

@vmaerten vmaerten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@pd93 pd93 merged commit dd8daa6 into main Mar 26, 2025
14 checks passed
@pd93 pd93 deleted the 2072-multiple-wildcard-matches branch March 26, 2025 22:17
pd93 added a commit that referenced this pull request Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants