Skip to content

Commit 8abca11

Browse files
committed
add documentation for console and file
1 parent b5a9cb4 commit 8abca11

File tree

1 file changed

+177
-4
lines changed

1 file changed

+177
-4
lines changed

v0.3/handbook/libraries/stdlib.md

Lines changed: 177 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ commit
718718
<ul>
719719
<li><strong>element</strong> - (optional) - the element which has focus during key-up or key-down</li>
720720
<li><strong>key-code</strong> - the key code of the key to be monitored</li>
721-
<li><strong>key</strong> - (optional) - the key to be monitored; an alternative to key-code for a premade list of keys:
721+
<li><strong>key</strong> - (optional) - the key to be monitored; an alternative to key-code for a pre-made list of keys:
722722
<ul>
723723
<li>"tab</li>
724724
<li>"enter"</li>
@@ -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,180 @@ bind
14561453
</tr>
14571454
</table>
14581455
1456+
## File
1457+
1458+
Watchers that access the filesystem. These watchers only work 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+
Write a string to a file
1516+
```
1517+
commit
1518+
[#file/write path: "test-file.txt" contents: "This will be in the file"]
1519+
```
1520+
</code>
1521+
</td>
1522+
</tr>
1523+
</table>
1524+
1525+
<table class="libitem">
1526+
<tr>
1527+
<td colspan="2">
1528+
<b>#file/error</b> - stores information relating to file access errors
1529+
</td>
1530+
</tr>
1531+
1532+
<tr>
1533+
<td>
1534+
<ul>
1535+
<li><strong>code</strong> - The error code</li>
1536+
<li><strong>message</strong> - The error message</li>
1537+
</ul>
1538+
</td>
1539+
<td>
1540+
<code>
1541+
Display a message when a file does not exist
1542+
```
1543+
search
1544+
[#file/read path error: [code: "ENOENT"]]
1545+
commit
1546+
[#console/error text: "Could not file file {{path}}"]
1547+
```
1548+
</code>
1549+
</td>
1550+
</tr>
1551+
</table>
1552+
1553+
## Console
1554+
1555+
Write text to the console
1556+
1557+
<table class="libitem">
1558+
<tr>
1559+
<td colspan="2">
1560+
<b>#console/log</b> - write info to the console
1561+
</td>
1562+
</tr>
1563+
1564+
<tr>
1565+
<td>
1566+
<ul>
1567+
<li><strong>text</strong> - The text to write to the console. Text will also be written to stdout.</li>
1568+
</ul>
1569+
</td>
1570+
<td>
1571+
<code>
1572+
Write a message to the console.
1573+
```
1574+
commit
1575+
[#console/log text: "Hello world!"]
1576+
```
1577+
</code>
1578+
</td>
1579+
</tr>
1580+
</table>
1581+
1582+
<table class="libitem">
1583+
<tr>
1584+
<td colspan="2">
1585+
<b>#console/warn</b> - write a warning to the console
1586+
</td>
1587+
</tr>
1588+
1589+
<tr>
1590+
<td>
1591+
<ul>
1592+
<li><strong>text</strong> - The text to write to the console.</li>
1593+
</ul>
1594+
</td>
1595+
<td>
1596+
<code>
1597+
Write a warning to the console.
1598+
```
1599+
commit
1600+
[#console/warn text: "Memory is running low."]
1601+
```
1602+
</code>
1603+
</td>
1604+
</tr>
1605+
</table>
1606+
1607+
<table class="libitem">
1608+
<tr>
1609+
<td colspan="2">
1610+
<b>#console/error</b> - write an error to the console.
1611+
</td>
1612+
</tr>
1613+
1614+
<tr>
1615+
<td>
1616+
<ul>
1617+
<li><strong>text</strong> - The text to write to the console. Text will also be written to stderr.</li>
1618+
</ul>
1619+
</td>
1620+
<td>
1621+
<code>
1622+
Write an error in the console.
1623+
```
1624+
commit
1625+
[#console/error text: "Access is Denied"]
1626+
```
1627+
</code>
1628+
</td>
1629+
</tr>
1630+
</table>
1631+
14591632
{% endraw %}

0 commit comments

Comments
 (0)