@@ -1674,4 +1674,175 @@ bind
1674
1674
</tr>
1675
1675
</table>
1676
1676
1677
+ ## File
1678
+
1679
+ A library for accessing the filesystem. This library only works when Eve is run in headless mode.
1680
+
1681
+ <table class="libitem">
1682
+ <tr>
1683
+ <td colspan="2">
1684
+ <b>#file/read</b> - read the specified file
1685
+ </td>
1686
+ </tr>
1687
+
1688
+ <tr>
1689
+ <td>
1690
+ <ul>
1691
+ <li><strong>path</strong> - The path of the file to be read.</li>
1692
+ <li><strong>encoding</strong> - (optional) - The encoding of the file. The default is utf-8.</li>
1693
+ <li><strong>error</strong> - (optional) - If an error is encountered when attempting to read the file, it will be stored here as a #file/error.</li>
1694
+ <li><strong>contents</strong> - The contents of the file. This attribute will have a value once the entire contents of the file are read.</li>
1695
+ </ul>
1696
+ </td>
1697
+ <td>
1698
+ <code>
1699
+ Read a file
1700
+ ```
1701
+ commit
1702
+ [#file/read #my-file path: "test-file.txt"]
1703
+ ```
1704
+
1705
+ Display the contents of the file
1706
+ ```
1707
+ search
1708
+ [#my-file contents]
1709
+ commit
1710
+ [#console/log text: contents]
1711
+ ```
1712
+ </code>
1713
+ </td>
1714
+ </tr>
1715
+ </table>
1716
+
1717
+ <table class="libitem">
1718
+ <tr>
1719
+ <td colspan="2">
1720
+ <b>#file/read</b> - read the specified file
1721
+ </td>
1722
+ </tr>
1723
+
1724
+ <tr>
1725
+ <td>
1726
+ <ul>
1727
+ <li><strong>path</strong> - The path of the file to be written.</li>
1728
+ <li><strong>encoding</strong> - (optional) - The encoding of the file. The default is utf-8.</li>
1729
+ <li><strong>contents</strong> - The string that will be written to the file</li>
1730
+ <li><strong>error</strong> - (optional) - If an error is encountered when attempting to read the file, it will be stored here as a #file/error.</li>
1731
+ <li><strong>#file/complete</strong> - When the contents are written successfully, the record will be tagged #file/complete.</li>
1732
+ </ul>
1733
+ </td>
1734
+ <td>
1735
+ <code>
1736
+ ```
1737
+ commit
1738
+ [#file/write path: "test-file.txt" contents: "This will be in the file"]
1739
+ ```
1740
+ </code>
1741
+ </td>
1742
+ </tr>
1743
+ </table>
1744
+
1745
+ <table class="libitem">
1746
+ <tr>
1747
+ <td colspan="2">
1748
+ <b>#file/error</b> - stores information relating to file access errors
1749
+ </td>
1750
+ </tr>
1751
+
1752
+ <tr>
1753
+ <td>
1754
+ <ul>
1755
+ <li><strong>code</strong> - The error code</li>
1756
+ <li><strong>message</strong> - The error message</li>
1757
+ </ul>
1758
+ </td>
1759
+ <td>
1760
+ <code>
1761
+ ```
1762
+ search
1763
+ [#file/read path error: [code: "ENOENT"]]
1764
+ commit
1765
+ [#console/error text: "Could not file file {{path}}"]
1766
+ ```
1767
+ </code>
1768
+ </td>
1769
+ </tr>
1770
+ </table>
1771
+
1772
+ ## Console
1773
+
1774
+ Write text to the console
1775
+
1776
+ <table class="libitem">
1777
+ <tr>
1778
+ <td colspan="2">
1779
+ <b>#console/log</b> - write info to the console
1780
+ </td>
1781
+ </tr>
1782
+
1783
+ <tr>
1784
+ <td>
1785
+ <ul>
1786
+ <li><strong>text</strong> - The text to write to the console. Text will also be written to stdout.</li>
1787
+ </ul>
1788
+ </td>
1789
+ <td>
1790
+ <code>
1791
+ ```
1792
+ commit
1793
+ [#console/log text: "Hello world!"]
1794
+ ```
1795
+ </code>
1796
+ </td>
1797
+ </tr>
1798
+ </table>
1799
+
1800
+ <table class="libitem">
1801
+ <tr>
1802
+ <td colspan="2">
1803
+ <b>#console/warn</b> - write a warning to the console
1804
+ </td>
1805
+ </tr>
1806
+
1807
+ <tr>
1808
+ <td>
1809
+ <ul>
1810
+ <li><strong>text</strong> - The text to write to the console.</li>
1811
+ </ul>
1812
+ </td>
1813
+ <td>
1814
+ <code>
1815
+ ```
1816
+ commit
1817
+ [#console/warn text: "Memory is running low."]
1818
+ ```
1819
+ </code>
1820
+ </td>
1821
+ </tr>
1822
+ </table>
1823
+
1824
+ <table class="libitem">
1825
+ <tr>
1826
+ <td colspan="2">
1827
+ <b>#console/error</b> - write an error to the console.
1828
+ </td>
1829
+ </tr>
1830
+
1831
+ <tr>
1832
+ <td>
1833
+ <ul>
1834
+ <li><strong>text</strong> - The text to write to the console. Text will also be written to stderr.</li>
1835
+ </ul>
1836
+ </td>
1837
+ <td>
1838
+ <code>
1839
+ ```
1840
+ commit
1841
+ [#console/error text: "Access is Denied"]
1842
+ ```
1843
+ </code>
1844
+ </td>
1845
+ </tr>
1846
+ </table>
1847
+
1677
1848
{% endraw %}
0 commit comments