T
Task3mo ago
JonZeolla

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}}'
GitHub
Map variables experiment · Issue #1585 · go-task/task
WarningAll experimental features are subject to breaking changes and/or removal at any time. We strongly recommend that you do not use these features in a production environment. They are intended ...
1 Reply
andreynering
andreynering3mo ago
Hi @JonZeolla, I suggest you do make a comment on https://github.com/go-task/task/issues/1585 with your proposal. There, it would be less likely to be forgotten, as Discord is more for questions than feature requests.
GitHub
Map variables experiment · Issue #1585 · go-task/task
WarningAll experimental features are subject to breaking changes and/or removal at any time. We strongly recommend that you do not use these features in a production environment. They are intended ...
Want results from more Discord servers?
Add your server