@@ -2,107 +2,113 @@ version: '3'
22
33tasks :
44 default :
5- - task : dynamic
6- - task : string
7- - task : bool
8- - task : int
9- - task : string-array
105 - task : map
11- - task : for-string
12- - task : for-int
13- - task : for-map
14- - task : for-multi-layer-map
6+ - task : nested-map
7+ - task : slice
8+ - task : ref
9+ - task : ref-sh
10+ - task : ref-dep
11+ - task : ref-resolver
12+ - task : json
1513
16- dynamic :
14+ map :
1715 vars :
18- STRING_A : ' $echo "A"'
19- STRING_B : ' $echo {{.STRING_A}}B'
20- STRING_C : ' $echo {{.STRING_B}}C'
16+ MAP :
17+ map : {"name":"Alice","age":30,"children":[{"name":"Bob","age":5},{"name":"Charlie","age":3},{"name":"Diane","age":1}]}
2118 cmds :
22- - echo '{{.STRING_C}}'
19+ - task : print-story
20+ vars :
21+ VAR :
22+ ref : .MAP
2323
24- string :
24+ nested-map :
2525 vars :
26- STRING_A : ' A'
27- STRING_B : ' {{.STRING_A}}B'
28- STRING_C : ' {{.STRING_B}}C'
26+ FOO : " foo"
27+ nested :
28+ map :
29+ variables :
30+ work : " {{.FOO}}"
2931 cmds :
30- - echo ' {{.STRING_C}}'
32+ - echo {{.nested.variables.work}}
3133
32- bool :
34+ slice :
3335 vars :
34- BOOL_TRUE : true
35- BOOL_FALSE : false
36- BOOL_A : ' {{and .BOOL_TRUE .BOOL_FALSE}}'
37- BOOL_B : ' {{or .BOOL_TRUE .BOOL_FALSE}}'
38- BOOL_C : ' {{not .BOOL_TRUE}}'
36+ FOO : " foo"
37+ BAR : " bar"
38+ slice_variables_work : ["{{.FOO}}","{{.BAR}}"]
3939 cmds :
40- - echo '{{if .BOOL_TRUE}}A:{{.BOOL_A}} B:{{.BOOL_B }} C:{{.BOOL_C}}{{end}}'
40+ - echo {{index .slice_variables_work 0 }} {{index .slice_variables_work 1}}
4141
42- int :
42+ ref :
4343 vars :
44- INT_100 : 100
45- INT_10 : 10
44+ MAP :
45+ map : {"name":"Alice","age":30,"children":[{"name":"Bob","age":5},{"name":"Charlie","age":3},{"name":"Diane","age":1}]}
46+ MAP_REF :
47+ ref : .MAP
4648 cmds :
47- - echo '100 + 10 = {{add .INT_100 .INT_10}}'
48- - echo '100 - 10 = {{sub .INT_100 .INT_10}}'
49- - echo '100 * 10 = {{mul .INT_100 .INT_10}}'
50- - echo '100 / 10 = {{div .INT_100 .INT_10}}'
49+ - task : print-story
50+ vars :
51+ VAR :
52+ ref : .MAP_REF
5153
52- string-array :
54+ ref-sh :
5355 vars :
54- ARRAY_1 : ['A', 'B', 'C']
55- ARRAY_2 : ['D', 'E', 'F']
56+ JSON_STRING :
57+ sh : echo '{"name":"Alice","age":30,"children":[{"name":"Bob","age":5},{"name":"Charlie","age":3},{"name":"Diane","age":1}]}'
58+ JSON : " fromJson {{.JSON_STRING}}"
59+ MAP_REF :
60+ ref : .JSON
5661 cmds :
57- - echo '{{append .ARRAY_1 "D"}}'
58- - echo '{{concat .ARRAY_1 .ARRAY_2}}'
59- - echo '{{join " " .ARRAY_1}}'
62+ - task : print-story
63+ vars :
64+ VAR :
65+ ref : .MAP_REF
6066
61- map :
67+ ref-dep :
6268 vars :
63- MAP_1 : {A: 1, B: 2, C: 3}
64- MAP_2 : {B: 4, C: 5, D: 6}
65- MAP_3 : {C: 7, D: 8, E: 9}
66- cmds :
67- - echo '{{merge .MAP_1 .MAP_2 .MAP_3}}'
69+ MAP :
70+ map : {"name":"Alice","age":30,"children":[{"name":"Bob","age":5},{"name":"Charlie","age":3},{"name":"Diane","age":1}]}
71+ deps :
72+ - task : print-story
73+ vars :
74+ VAR :
75+ ref : .MAP
6876
69- for-string :
77+ ref-resolver :
7078 vars :
71- LIST : [foo, bar, baz]
79+ MAP :
80+ map : {"name":"Alice","age":30,"children":[{"name":"Bob","age":5},{"name":"Charlie","age":3},{"name":"Diane","age":1}]}
81+ MAP_REF :
82+ ref : .MAP
7283 cmds :
73- - for :
74- var : LIST
75- cmd : echo {{.ITEM}}
84+ - task : print-var
85+ vars :
86+ VAR :
87+ ref : (index .MAP_REF.children 0).name
7688
77- for-int :
89+ json :
7890 vars :
79- LIST : [1, 2, 3]
91+ JSON_STRING :
92+ sh : cat example.json
93+ JSON :
94+ ref : " fromJson .JSON_STRING"
8095 cmds :
81- - for :
82- var : LIST
83- cmd : echo {{add .ITEM 100}}
96+ - task : print-story
97+ vars :
98+ VAR :
99+ ref : .JSON
84100
85- for-map :
86- vars :
87- MAP :
88- KEY_1 : value_1
89- KEY_2 : value_2
90- KEY_3 : value_3
101+ print-var :
91102 cmds :
92- - for :
93- var : MAP
94- cmd : echo {{.KEY}} {{.ITEM}}
103+ - echo "{{.VAR}}"
95104
96- for-multi-layer-map :
97- vars :
98- MAP :
99- KEY_1 :
100- SUBKEY : sub_value_1
101- KEY_2 :
102- SUBKEY : sub_value_2
103- KEY_3 :
104- SUBKEY : sub_value_3
105+ print-story :
105106 cmds :
106- - for :
107- var : MAP
108- cmd : echo {{.KEY}} {{.ITEM.SUBKEY}}
107+ - >-
108+ echo "{{.VAR.name}} has {{len .VAR.children}} children called
109+ {{- $children := .VAR.children -}}
110+ {{- range $i, $child := $children -}}
111+ {{- if lt $i (sub (len $children) 1)}} {{$child.name -}},
112+ {{- else}} and {{$child.name -}}
113+ {{- end -}}
114+ {{- end -}}"
0 commit comments