Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace nomnom with commander #367

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry to be annoying, and it seems like this project might be unmaintained anyway, but is this part necessary to use commander instead? Just curious, I was trying to find the nomnom dependency in CoffeeScript and found this PR which I really appreciate and trying to understand if this affects how jison needs to be installed is all.


Usage from the command line
-----------------------
Expand Down
71 changes: 15 additions & 56 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file> <lexfile>', {isDefault: true})
.option('-j, --json', 'force jison to expect a grammar in JSON format')
.option('-o, --outfile <FILE>', 'Filename and base module name of the generated parser')
.option('-t, --debug', 'Debug mode')
.option('-m, --module-type <TYPE>', 'The type of module to generate (commonjs, amd, js)')
.option('-p, --parser-type <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;
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down