github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0071.yml (about) 1 doc_meta: | 2 folder: cmd-func 3 title: read/write file 4 head: | 5 Showcase how to use readFile and writeFile cmd 6 7 sections: 8 - title: my story text file reference 9 filelookup: d0070.txt 10 11 - title: How to use? 12 content: | 13 * writeFile 14 conent: the static or dynamic content 15 filename: the filename to write to 16 dir: directory of the file to save to 17 * readFile 18 filename: the filename to read from 19 dir: directory of the file to read from 20 reg: the register var name of the file content will be loaded to 21 22 - title: Demo 23 log: yes 24 25 notes: 26 goal: 27 - use dvar ref to load common file only 28 - add cmd readFile and register to a named var 29 - add cmd write file to save to a file 30 31 dvars: 32 33 - name: mystory 34 ref: d0070.txt 35 36 tasks: 37 38 - name: task 39 task: 40 - func: call 41 do: 42 - case1 43 - case2 44 45 - name: case1 46 task: 47 48 - func: cmd 49 do: 50 - 51 name: print 52 cmd: "{{.mystory}}" 53 54 - 55 name: writeFile 56 desc: write content to a file 57 cmd: 58 content: "{{.mystory}}" 59 filename: mystory.txt 60 dir: /tmp 61 62 - 63 name: readFile 64 desc: read content of a file and register it to a var 65 cmd: 66 filename: mystory.txt 67 dir: /tmp 68 reg: my_interesting_story 69 70 - 71 name: print 72 cmd: "{{.my_interesting_story}}" 73 74 - name: case2 75 task: 76 77 - func: cmd 78 do: 79 - 80 name: print 81 cmd: "{{.mystory}}" 82 83 - 84 name: writeFile 85 desc: write content to a file 86 cmd: 87 content: "{{.mystory}}" 88 # filename: mystory.txt 89 # dir: /tmp 90 filepath: /tmp/mystory.txt 91 92 - 93 name: readFile 94 desc: read content of a file and register it to a var 95 cmd: 96 # filename: mystory.txt 97 # dir: /tmp 98 filepath: /tmp/mystory.txt 99 reg: my_interesting_story 100 101 - 102 name: print 103 cmd: "{{.my_interesting_story}}"