.MATCH variable as an array.
Taskfile.yaml
Demo and Output
Use wildcard task names with * to capture multiple dynamic arguments stored in the .MATCH variable.
.MATCH variable as an array.
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}}'
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
task "service:nginx hello-world"