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

Modified cli.js to accept a -n parameter to set the module name used in gene… #368

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 10 additions & 4 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ function getCommandlineOptions () {
false,
help : 'Debug mode'
})
.option('module-name', {
abbr : 'n',
metavar : 'string',
help : 'The name of the module to generate, otherwise the base name of the outfile will be used '
})
.option('module-type', {
abbr : 'm',
default:
Expand Down Expand Up @@ -94,8 +99,9 @@ cli.main = function cliMain(opts) {
name = name.replace(/\..*$/g, '');

opts.outfile = opts.outfile || (name + '.js');
if (!opts.moduleName && name) {
opts.moduleName = name.replace(/-\w/g,

if (!opts['module-name'] && name) {
opts['module-name'] = name.replace(/-\w/g,
function (match) {
return match.charAt(1).toUpperCase();
});
Expand Down Expand Up @@ -142,8 +148,8 @@ cli.generateParserString = function generateParserString(opts, grammar) {
if (opts['parser-type']) {
settings.type = opts['parser-type'];
}
if (opts.moduleName) {
settings.moduleName = opts.moduleName;
if (opts['module-name']) {
settings.moduleName = opts['module-name'];
}
settings.debug = opts.debug;
if (!settings.moduleType) {
Expand Down