Skip to content

Commit 57912e6

Browse files
authored
Merge pull request #13 from cmontella/add/console-and-file
Document console and file watchers
2 parents b5a9cb4 + f510957 commit 57912e6

File tree

2 files changed

+173
-3
lines changed

2 files changed

+173
-3
lines changed

_layouts/default.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ <h1><img alt="EVE" src="https://witheve.github.io/assets/images/wordmark.svg" />
7171
<li><a href="/v0.3/handbook/libraries/stdlib/#canvas">Canvas</a></li>
7272
<li><a href="/v0.3/handbook/libraries/stdlib/#ui">UI</a></li>
7373
<li><a href="/v0.3/handbook/libraries/stdlib/#system">System</a></li>
74+
<li><a href="/v0.3/handbook/libraries/stdlib/#file">File</a></li>
75+
<li><a href="/v0.3/handbook/libraries/stdlib/#console">Console</a></li>
7476

7577
</ul>
7678
</li>

v0.3/handbook/libraries/stdlib.md

Lines changed: 171 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,18 +1436,15 @@ The system library provides various system-level utilities for Eve.
14361436
<td>
14371437
<code>
14381438
Commits a timer that ticks every 1000 milliseconds
1439-
14401439
```
14411440
commit
14421441
[#system/timer resolution: 1000]
14431442
```
14441443
14451444
Displays the current time
1446-
14471445
```
14481446
search
14491447
[#system/timer hour minute second]
1450-
14511448
bind
14521449
[#ui/text text: "{{hour}}:{{minute}}:{{second}}"]
14531450
```
@@ -1456,4 +1453,175 @@ bind
14561453
</tr>
14571454
</table>
14581455
1456+
## File
1457+
1458+
A library for accessing the filesystem. This library only works when Eve is run in headless mode.
1459+
1460+
<table class="libitem">
1461+
<tr>
1462+
<td colspan="2">
1463+
<b>#file/read</b> - read the specified file
1464+
</td>
1465+
</tr>
1466+
1467+
<tr>
1468+
<td>
1469+
<ul>
1470+
<li><strong>path</strong> - The path of the file to be read.</li>
1471+
<li><strong>encoding</strong> - (optional) - The encoding of the file. The default is utf-8.</li>
1472+
<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>
1473+
<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>
1474+
</ul>
1475+
</td>
1476+
<td>
1477+
<code>
1478+
Read a file
1479+
```
1480+
commit
1481+
[#file/read #my-file path: "test-file.txt"]
1482+
```
1483+
1484+
Display the contents of the file
1485+
```
1486+
search
1487+
[#my-file contents]
1488+
commit
1489+
[#console/log text: contents]
1490+
```
1491+
</code>
1492+
</td>
1493+
</tr>
1494+
</table>
1495+
1496+
<table class="libitem">
1497+
<tr>
1498+
<td colspan="2">
1499+
<b>#file/read</b> - read the specified file
1500+
</td>
1501+
</tr>
1502+
1503+
<tr>
1504+
<td>
1505+
<ul>
1506+
<li><strong>path</strong> - The path of the file to be written.</li>
1507+
<li><strong>encoding</strong> - (optional) - The encoding of the file. The default is utf-8.</li>
1508+
<li><strong>contents</strong> - The string that will be written to the file</li>
1509+
<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>
1510+
<li><strong>#file/complete</strong> - When the contents are written successfully, the record will be tagged #file/complete.</li>
1511+
</ul>
1512+
</td>
1513+
<td>
1514+
<code>
1515+
```
1516+
commit
1517+
[#file/write path: "test-file.txt" contents: "This will be in the file"]
1518+
```
1519+
</code>
1520+
</td>
1521+
</tr>
1522+
</table>
1523+
1524+
<table class="libitem">
1525+
<tr>
1526+
<td colspan="2">
1527+
<b>#file/error</b> - stores information relating to file access errors
1528+
</td>
1529+
</tr>
1530+
1531+
<tr>
1532+
<td>
1533+
<ul>
1534+
<li><strong>code</strong> - The error code</li>
1535+
<li><strong>message</strong> - The error message</li>
1536+
</ul>
1537+
</td>
1538+
<td>
1539+
<code>
1540+
```
1541+
search
1542+
[#file/read path error: [code: "ENOENT"]]
1543+
commit
1544+
[#console/error text: "Could not file file {{path}}"]
1545+
```
1546+
</code>
1547+
</td>
1548+
</tr>
1549+
</table>
1550+
1551+
## Console
1552+
1553+
Write text to the console
1554+
1555+
<table class="libitem">
1556+
<tr>
1557+
<td colspan="2">
1558+
<b>#console/log</b> - write info to the console
1559+
</td>
1560+
</tr>
1561+
1562+
<tr>
1563+
<td>
1564+
<ul>
1565+
<li><strong>text</strong> - The text to write to the console. Text will also be written to stdout.</li>
1566+
</ul>
1567+
</td>
1568+
<td>
1569+
<code>
1570+
```
1571+
commit
1572+
[#console/log text: "Hello world!"]
1573+
```
1574+
</code>
1575+
</td>
1576+
</tr>
1577+
</table>
1578+
1579+
<table class="libitem">
1580+
<tr>
1581+
<td colspan="2">
1582+
<b>#console/warn</b> - write a warning to the console
1583+
</td>
1584+
</tr>
1585+
1586+
<tr>
1587+
<td>
1588+
<ul>
1589+
<li><strong>text</strong> - The text to write to the console.</li>
1590+
</ul>
1591+
</td>
1592+
<td>
1593+
<code>
1594+
```
1595+
commit
1596+
[#console/warn text: "Memory is running low."]
1597+
```
1598+
</code>
1599+
</td>
1600+
</tr>
1601+
</table>
1602+
1603+
<table class="libitem">
1604+
<tr>
1605+
<td colspan="2">
1606+
<b>#console/error</b> - write an error to the console.
1607+
</td>
1608+
</tr>
1609+
1610+
<tr>
1611+
<td>
1612+
<ul>
1613+
<li><strong>text</strong> - The text to write to the console. Text will also be written to stderr.</li>
1614+
</ul>
1615+
</td>
1616+
<td>
1617+
<code>
1618+
```
1619+
commit
1620+
[#console/error text: "Access is Denied"]
1621+
```
1622+
</code>
1623+
</td>
1624+
</tr>
1625+
</table>
1626+
14591627
{% endraw %}

0 commit comments

Comments
 (0)