mirror of
https://github.com/go-task/task.git
synced 2026-06-23 12:45:52 +00:00
54 lines
1.4 KiB
YAML
54 lines
1.4 KiB
YAML
version: '3'
|
|
|
|
tasks:
|
|
default:
|
|
- task: map
|
|
- task: json
|
|
- task: yaml
|
|
|
|
map:
|
|
vars:
|
|
MAP:
|
|
map: {"name":"Alice","age":30,"children":[{"name":"Bob","age":5},{"name":"Charlie","age":3},{"name":"Diane","age":1}]}
|
|
cmds:
|
|
- >-
|
|
echo "{{.MAP.name}} has {{len .MAP.children}} children called
|
|
{{- $children := .MAP.children -}}
|
|
{{- range $i, $child := $children -}}
|
|
{{- if lt $i (sub (len $children) 1)}} {{$child.name -}},
|
|
{{- else}} and {{$child.name -}}
|
|
{{- end -}}
|
|
{{- end -}}"
|
|
|
|
json:
|
|
vars:
|
|
JSON_STRING:
|
|
sh: cat example.json
|
|
JSON:
|
|
json: "{{.JSON_STRING}}"
|
|
cmds:
|
|
- >-
|
|
echo "{{.JSON.name}} has {{len .JSON.children}} children called
|
|
{{- $children := .JSON.children -}}
|
|
{{- range $i, $child := $children -}}
|
|
{{- if lt $i (sub (len $children) 1)}} {{$child.name -}},
|
|
{{- else}} and {{$child.name -}}
|
|
{{- end -}}
|
|
{{- end -}}"
|
|
|
|
yaml:
|
|
vars:
|
|
YAML_STRING:
|
|
sh: cat example.yaml
|
|
YAML:
|
|
yaml: "{{.YAML_STRING}}"
|
|
cmds:
|
|
- >-
|
|
echo "{{.YAML.name}} has {{len .YAML.children}} children called
|
|
{{- $children := .YAML.children -}}
|
|
{{- range $i, $child := $children -}}
|
|
{{- if lt $i (sub (len $children) 1)}} {{$child.name -}},
|
|
{{- else}} and {{$child.name -}}
|
|
{{- end -}}
|
|
{{- end -}}"
|