@@ -1436,18 +1436,15 @@ The system library provides various system-level utilities for Eve.
1436
1436
<td>
1437
1437
<code>
1438
1438
Commits a timer that ticks every 1000 milliseconds
1439
-
1440
1439
```
1441
1440
commit
1442
1441
[ #system/timer resolution: 1000]
1443
1442
```
1444
1443
1445
1444
Displays the current time
1446
-
1447
1445
```
1448
1446
search
1449
1447
[ #system/timer hour minute second]
1450
-
1451
1448
bind
1452
1449
[ #ui/text text: "{{hour}}:{{minute}}:{{second}}"]
1453
1450
```
@@ -1456,4 +1453,175 @@ bind
1456
1453
</tr>
1457
1454
</table>
1458
1455
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
+
1459
1627
{% endraw %}
0 commit comments