github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0055.yml (about) 1 doc_meta: | 2 folder: flow-controll 3 title: if condition advanced 4 head: | 5 Showcase you can use if condition for cmd func and call func too 6 7 sections: 8 - title: What's good about it when you use if with call func? 9 content: | 10 The call func actually is very powerfully to create a execution branch with its own stack. So if you use a if condition to call another task, it actually separate the implementation with your own main flow. 11 12 Also with multiple if, it is similar to convert the workflow to if/if else, or switch/case etc. Or with embeded if in callee, you could create branched flows so this enrichs the workflow management in very simple way compare to other tools 13 14 - title: Demo 15 log: yes 16 17 notes: 18 goal: 19 - test the if condition works for cmd and call 20 21 tasks: 22 - 23 name: task 24 task: 25 26 - func: call 27 do: 28 - taska 29 if: "false" 30 31 - func: cmd 32 dvars: 33 - name: greet 34 value: hello 35 flags: [vvvv] 36 if: "true" 37 38 - func: call 39 do: 40 - taska 41 if: "true" 42 43 - name: taska 44 task: 45 - func: shell 46 desc: greet var will be no value as it is a local var for cmd step 47 do: 48 - echo "hello from taska" 49 - echo "{{.greet}} from taska"