JonZeolla
JonZeolla
TTask
Created by JonZeolla on 8/28/2024 in #help
Using sh to generate a map?
I've been taking a poke at https://github.com/go-task/task/issues/1585 very briefly but it made me wonder if there would be interest in something that would support using the output of a sh: into a map. This would allow me to create complex tasks or scripts that generate valid JSON for consumption by task (something I already do regularly for GitHub Actions matrixes). For instance:
---
version: 3

tasks:
foo:
vars:
BAZ:
sh: 'echo "{a: 1, b: 2, c: 3}"'
FOO:
map: '{{.BAZ}}'
cmds:
- 'echo {{.FOO.a}}'
---
version: 3

tasks:
foo:
vars:
BAZ:
sh: 'echo "{a: 1, b: 2, c: 3}"'
FOO:
map: '{{.BAZ}}'
cmds:
- 'echo {{.FOO.a}}'
Or, a more streamlined:
---
version: 3

tasks:
foo:
vars:
FOO:
map:
sh: 'echo "{a: 1, b: 2, c: 3}"'
cmds:
- 'echo {{.FOO.a}}'
---
version: 3

tasks:
foo:
vars:
FOO:
map:
sh: 'echo "{a: 1, b: 2, c: 3}"'
cmds:
- 'echo {{.FOO.a}}'
2 replies