github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0195.yml (about) 1 doc_meta: | 2 folder: cmd-func 3 title: tmp file 4 head: | 5 This shows how to create a tmp file with content 6 7 params: 8 * reg: register the file path to a name, so you can reference the file using this reg name 9 * content: the content of the file to be created 10 11 Note: 12 You will have to manage to delete or clean up the tmp file in either step finally or task finally if you wish to 13 14 sections: 15 - title: Demo 16 log: yes 17 18 tasks: 19 20 - 21 name: task 22 task: 23 - 24 func: cmd 25 do: 26 - name: tmpFile 27 cmd: 28 reg: myfile 29 content: hello, world 30 - name: print 31 cmd: 'filename: {{.myfile}}' 32 33 - name: readFile 34 cmd: 35 filename: '{{.myfile}}' 36 reg: my_file_content 37 - name: print 38 cmd: 'file content: {{.my_file_content}}' 39 40 41 finally: 42 - 43 func: shell 44 do: 'cat {{.myfile}}' 45 - 46 func: shell 47 desc: | 48 this shows you delete the tmp file in step finally 49 do: 'rm -f {{.myfile}}' 50 - 51 func: shell 52 do: 'cat {{.myfile}}' 53 flags: [ignoreError] 54 finally: 55 - 56 func: shell 57 desc: | 58 this shows you delete the tmp file in task finally 59 this is deactivated 60 just for reference 61 dox: 'rm -f {{.myfile}}' 62 63 - 64 func: shell 65 do: 'cat {{.myfile}}' 66 flags: [ignoreError]