Browse files

Provide a command-line runner for the library

  • Loading branch information...
1 parent 1269e1c commit d267dd0a1ae633a7b3cf68456eda92f67d529b61 @bergie bergie committed May 30, 2013
Showing with 23 additions and 0 deletions.
  1. +19 −0 bin/fbp
  2. +4 −0 package.json
View
19 bin/fbp
@@ -0,0 +1,19 @@
+#!/usr/bin/env node
+// vim: set filetype=javascript:
+var path = require('path');
+var fs = require('fs');
+var parser = require('../lib/fbp');
+
+if (process.argv.length != 3) {
+ console.log("Usage:\n$ fbp somefile.fbp");
+ process.exit(0);
+}
+
+var file = path.resolve(process.cwd(), process.argv[2]);
+if (!fs.existsSync(file)) {
+ console.log("File " + file + " not found");
+ process.exit(1);
+}
+
+var result = parser.parse(fs.readFileSync(file, 'utf-8'));
+console.log(JSON.stringify(result, null, 2));
View
4 package.json
@@ -23,5 +23,9 @@
"keywords": [],
"scripts": {
"test": "grunt test"
+ },
+ "main": "./lib/fbp",
+ "bin": {
+ "fbp": "./bin/fbp"
}
}

0 comments on commit d267dd0

Please sign in to comment.