Skip to main content
Wildcard arguments allow you to capture dynamic segments of a task name and use them as variables. The matched segments are stored in the .MATCH variable as an array.
Taskfile.yaml
version: '3'
tasks:
  service:*:*:
    vars:
      SERVICE_NAME: "{{index .MATCH 0}}"
      REPLICAS: "{{index .MATCH 1}}"
    cmds:
      - 'echo Service Name: {{.SERVICE_NAME}}'
      - 'echo Replicas: {{.REPLICAS}}'

  service:*:
    vars:
      SERVICE_NAME: "{{index .MATCH 0}}"
    cmds:
      - 'echo Service Name: {{.SERVICE_NAME}}'
Demo and Output
ubuntu@touted-mite:~$ task service:nginx
task: [service:*] echo Service Name: nginx
Service Name: nginx

ubuntu@touted-mite:~$ task service:nginx:2
task: [service:*:*] echo Service Name: nginx
Service Name: nginx
task: [service:*:*] echo Replicas: 2
Replicas: 2
You can also use whitespace in wildcard arguments by quoting them:
task "service:nginx hello-world"

Build docs developers (and LLMs) love