diff options
author | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-03-31 15:54:26 -0700 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-03-31 15:54:26 -0700 |
commit | 2d29121e2e6a49912cd5e635974737d1002b6d3e (patch) | |
tree | c1c969bac87f3574bc9b1fb0edc0a85a5fa48ee3 /bin/gitbook.js | |
parent | 36b961c5390eb6c5829b22bc143634a150a5eb38 (diff) | |
download | gitbook-2d29121e2e6a49912cd5e635974737d1002b6d3e.zip gitbook-2d29121e2e6a49912cd5e635974737d1002b6d3e.tar.gz gitbook-2d29121e2e6a49912cd5e635974737d1002b6d3e.tar.bz2 |
Add lex sub-command to gitbook binary
The lex command is useful for debugging files and seeing how they are
parsed
Diffstat (limited to 'bin/gitbook.js')
-rwxr-xr-x | bin/gitbook.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/bin/gitbook.js b/bin/gitbook.js index 6ec3e79..ad251f2 100755 --- a/bin/gitbook.js +++ b/bin/gitbook.js @@ -5,8 +5,11 @@ var _ = require('lodash'); var path = require('path'); var prog = require('commander'); +var fs = require('fs'); + var pkg = require('../package.json'); var generate = require("../lib/generate"); +var parse = require("../lib/parse"); var utils = require('./utils'); @@ -53,6 +56,16 @@ prog }); }); +prog +.command('lex <page_file>') +.description('Parse a page file into sections, display JSON dump') +.action(function(page_file) { + var parsed = parse.page(fs.readFileSync(page_file, 'utf-8')); + + console.log(JSON.stringify(parsed, null, 4)); +}); + + // Parse and fallback to help if no args if(_.isEmpty(prog.parse(process.argv).args) && process.argv.length === 2) { |