diff --git a/README.md b/README.md index 0c88e5f49..d9fceebcc 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Jison can be installed for [Node](http://nodejs.org) using [`npm`](http://github Using npm: - npm install jison -g + npm install jison --global --unsafe_perm --allow_root Usage from the command line ----------------------- diff --git a/lib/cli.js b/lib/cli.js index 338a23827..ab7b81695 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -3,60 +3,19 @@ function getCommandlineOptions () { "use strict"; var version = require('../package.json').version; - var opts = require("nomnom") - .script('jison') - .option('file', { - flag : true, - position : 0, - help : 'file containing a grammar' - }) - .option('lexfile', { - flag : true, - position : 1, - help : 'file containing a lexical grammar' - }) - .option('json', { - abbr : 'j', - flag : true, - help : 'force jison to expect a grammar in JSON format' - }) - .option('outfile', { - abbr : 'o', - metavar : 'FILE', - help : 'Filename and base module name of the generated parser' - }) - .option('debug', { - abbr : 't', - flag : true, - default: - false, - help : 'Debug mode' - }) - .option('module-type', { - abbr : 'm', - default: - 'commonjs', - metavar : 'TYPE', - help : 'The type of module to generate (commonjs, amd, js)' - }) - .option('parser-type', { - abbr : 'p', - default: - 'lalr', - metavar : 'TYPE', - help : 'The type of algorithm to use for the parser (lr0, slr,' + - 'lalr, lr)' - }) - .option('version', { - abbr : 'V', - flag : true, - help : 'print version and exit', - callback : function () { - return version; - } - }).parse(); - - return opts; + var program = require("commander"); + + program + .version(version) + .command('jison ', {isDefault: true}) + .option('-j, --json', 'force jison to expect a grammar in JSON format') + .option('-o, --outfile ', 'Filename and base module name of the generated parser') + .option('-t, --debug', 'Debug mode') + .option('-m, --module-type ', 'The type of module to generate (commonjs, amd, js)') + .option('-p, --parser-type ', 'The type of algorithm to use for the parser (lr0, slr, lalr, lr)') + .option('-V, --version', 'print version and exit') + + return program.parse(process.argv); } var cli = module.exports; @@ -140,14 +99,14 @@ cli.generateParserString = function generateParserString(opts, grammar) { var settings = grammar.options || {}; if (opts['parser-type']) { - settings.type = opts['parser-type']; + settings.type = opts['parser-type'] || 'lalr'; } if (opts.moduleName) { settings.moduleName = opts.moduleName; } settings.debug = opts.debug; if (!settings.moduleType) { - settings.moduleType = opts['module-type']; + settings.moduleType = opts['module-type'] || 'commonjs'; } var generator = new jison.Generator(grammar, settings); diff --git a/package.json b/package.json index 4ca2e4204..abc65de39 100644 --- a/package.json +++ b/package.json @@ -31,13 +31,13 @@ }, "dependencies": { "JSONSelect": "0.4.0", - "esprima": "1.1.x", + "cjson": "0.3.0", + "commander": "^2.15.1", + "ebnf-parser": "0.1.10", "escodegen": "1.3.x", + "esprima": "1.1.x", "jison-lex": "0.3.x", - "ebnf-parser": "0.1.10", - "lex-parser": "~0.1.3", - "nomnom": "1.5.2", - "cjson": "0.3.0" + "lex-parser": "~0.1.3" }, "devDependencies": { "test": "0.6.x",