Permalink
Browse files

added utilities

  • Loading branch information...
1 parent 6ed8e9d commit bd5a6ed905a3796bc6ca4458c82cb31ec63066b5 @tokuhirom committed Dec 28, 2011
Showing with 41 additions and 0 deletions.
  1. +19 −0 bin/gdbm-fetch
  2. +22 −0 bin/gdbm-list
View
@@ -0,0 +1,19 @@
+#!/usr/bin/env node
+"use strict";
+var gdbm = require('gdbm'),
+ util = require('util'),
+ undefined;
+
+console.log(process.argv);
+if (process.argv.length !== 4) {
+ util.puts("Usage: gdbm-fetch path key");
+ process.exit(1);
+}
+var path = process.argv[2];
+var key = process.argv[3];
+
+var db = new gdbm.GDBM();
+if (!db.open(path, 0, gdbm.GDBM_READER)) {
+ throw db.strerror();
+}
+util.puts(db.fetch(key));
View
@@ -0,0 +1,22 @@
+#!/usr/bin/env node
+"use strict";
+var gdbm = require('gdbm'),
+ util = require('util'),
+ undefined;
+
+console.log(process.argv);
+if (process.argv.length !== 3) {
+ util.puts("Usage: gdbm-list path");
+ process.exit(1);
+}
+var path = process.argv[2];
+
+var db = new gdbm.GDBM();
+if (!db.open(path, 0, gdbm.GDBM_READER)) {
+ throw db.strerror();
+}
+var key = db.firstkey();
+while (key) {
+ console.log(key);
+ key = db.nextkey(key);
+}

0 comments on commit bd5a6ed

Please sign in to comment.