aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2012-04-26 18:36:26 +0400
committerIgor Pashev <pashev.igor@gmail.com>2012-04-26 18:36:26 +0400
commit77806e14b46a2a8f1913b71501dd0793420d8962 (patch)
tree55da71191e84713329c4f5b3139a02eff6b8cf8e /examples
parent5586ff23cdade6860c354ea447109708bac7f9db (diff)
downloadnode-augeas-77806e14b46a2a8f1913b71501dd0793420d8962.tar.gz
Added simple example for async reading /etc/hosts
Diffstat (limited to 'examples')
-rw-r--r--examples/async-read-etc-hosts.js35
-rw-r--r--examples/heracles.js11
2 files changed, 35 insertions, 11 deletions
diff --git a/examples/async-read-etc-hosts.js b/examples/async-read-etc-hosts.js
new file mode 100644
index 0000000..701002c
--- /dev/null
+++ b/examples/async-read-etc-hosts.js
@@ -0,0 +1,35 @@
+var aug = require('../build/Release/libaugeas');
+
+
+/*
+ * Create Augeas object to work with '/etc/hosts'
+ * through 'hosts' lens:
+ */
+aug.createAugeas(
+ {lens: 'hosts', incl: '/etc/hosts'},
+ function(aug) {
+ if (!aug.error()) {
+ console.log(aug.get('/files/etc/hosts/1/ipaddr'));
+ console.log(aug.match('/files/etc/hosts/*/*'));
+ } else {
+ console.log('Sad, but true :-(');
+ }
+ }
+);
+console.log('Waiting for Augeas ...');
+
+/* Example output:
+Waiting for Augeas ...
+127.0.0.1
+[ '/files/etc/hosts/1/ipaddr',
+ '/files/etc/hosts/1/canonical',
+ '/files/etc/hosts/1/alias[1]',
+ '/files/etc/hosts/1/alias[2]',
+ '/files/etc/hosts/1/alias[3]',
+ '/files/etc/hosts/1/alias[4]',
+ '/files/etc/hosts/2/ipaddr',
+ '/files/etc/hosts/2/canonical',
+ '/files/etc/hosts/3/ipaddr',
+ '/files/etc/hosts/3/canonical' ]
+*/
+
diff --git a/examples/heracles.js b/examples/heracles.js
deleted file mode 100644
index 476a114..0000000
--- a/examples/heracles.js
+++ /dev/null
@@ -1,11 +0,0 @@
-var aug = require('../build/Release/libaugeas');
-
-aug.createAugeas(function(aug) {
- if (!aug.error()) {
- console.log(aug.get('/files/etc/hosts/1/ipaddr'));
- } else {
- console.log('Sad, but true :-(');
- }
- }
-);
-console.log('Waiting for Heracles :-)');