github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0105.yml (about) 1 doc_meta: | 2 folder: vars 3 title: var scope and accessibility 4 head: | 5 Showcase the var scope, how local var and global is diffent 6 7 sections: 8 - title: Demo 9 log: yes 10 11 notes: 12 goal: 13 - to test the var scope and its aviablity 14 15 vars: 16 tom: this is tom 17 18 tasks: 19 - 20 name: task 21 task: 22 - 23 func: cmd 24 vars: 25 jerry: this is jerry 26 do: 27 - name: print 28 cmd: '{{.tom}}' 29 - name: print 30 cmd: '{{.jerry}}' 31 32 - 33 func: cmd 34 do: 35 - name: print 36 cmd: '{{.jerry}}' 37 38 - name: reg 39 cmd: 40 name: hitom 41 desc: by default hitom is registered in to global context 42 value: 'hello, {{.tom}}' 43 44 - name: print 45 cmd: '{{.hitom}}' 46 47 48 - 49 func: cmd 50 do: 51 - name: print 52 desc: by default hitom is accessible from global context, that's why it is accessiable cross func 53 cmd: '{{.hitom}}' 54 55 - name: reg 56 cmd: 57 name: hijerry 58 desc: hijerry is registered to local scope only 59 value: 'hello, jerry' 60 flags: [localOnly] 61 62 - name: print 63 desc: expecting to see its value since it is still in same func scope 64 cmd: '{{.hijerry}}' 65 - 66 func: cmd 67 do: 68 - name: print 69 desc: hijerry is not accessible here and got <no value> 70 cmd: '{{.hijerry}}'