github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0108.yml (about) 1 doc_meta: | 2 folder: vars 3 title: task scope 4 head: | 5 So far, we have scoped vars and eventually they will be living in global runtime or local scope in a func, when you need to access the var across funcs, then you will have to define it in global runtime vars, or grouped vars scope, or register a var to glbale runtime. In this demo, we show that you can use taskScope flag to mark a dvar to be in task scope, so that you can easily access this task scope var accross different funcs 6 7 sections: 8 - title: Demo 9 log: yes 10 11 notes: 12 goal: 13 - to introduce a implicit task vars scope for easier sharing vars in same task 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 desc: jerry is in local scope so there is no value 37 cmd: '{{.jerry}}' 38 39 - 40 func: cmd 41 dvars: 42 - name: jerry 43 value: this is jerry in task scope 44 flags: 45 - taskScope 46 do: 47 - name: print 48 desc: this should print out the dvar value of jerry 49 cmd: '{{.jerry}}' 50 51 - 52 func: cmd 53 do: 54 - name: print 55 desc: this should print out the dvar value of jerry as it is declared jerry is in taskScope 56 cmd: '{{.jerry}}' 57 58 - 59 func: cmd 60 vars: 61 jerry: jerry is overrided in local scope 62 do: 63 - name: print 64 desc: var jerry in task scope is overrided by local var jerry 65 cmd: '{{.jerry}}' 66 67 - 68 func: cmd 69 do: 70 - name: print 71 desc: this should print out the jerry defined in task var scope 72 cmd: '{{.jerry}}'