|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
var util = require("util");
|
|
|
|
|
var fs = require("fs");
|
|
|
|
|
var path = require("path");
|
|
|
|
|
var PEG = require("../lib/peg");
|
|
|
|
|
|
|
|
|
|
/* Helpers */
|
|
|
|
@ -31,6 +32,8 @@ function printHelp() {
|
|
|
|
|
util.puts(" grammar)");
|
|
|
|
|
util.puts(" -o, --optimize <goal> select optimization for speed or size (default:");
|
|
|
|
|
util.puts(" speed)");
|
|
|
|
|
util.puts(" --plugin <plugin> use a specified plugin (can be specified");
|
|
|
|
|
util.puts(" multiple times)");
|
|
|
|
|
util.puts(" -v, --version print version information and exit");
|
|
|
|
|
util.puts(" -h, --help print help and exit");
|
|
|
|
|
}
|
|
|
|
@ -75,7 +78,8 @@ var exportVar = "module.exports";
|
|
|
|
|
var options = {
|
|
|
|
|
cache: false,
|
|
|
|
|
output: "source",
|
|
|
|
|
optimize: "speed"
|
|
|
|
|
optimize: "speed",
|
|
|
|
|
plugins: []
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
while (args.length > 0 && isOption(args[0])) {
|
|
|
|
@ -115,6 +119,22 @@ while (args.length > 0 && isOption(args[0])) {
|
|
|
|
|
options.optimize = args[0];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "--plugin":
|
|
|
|
|
nextArg();
|
|
|
|
|
if (args.length === 0) {
|
|
|
|
|
abort("Missing parameter of the --plugin option.");
|
|
|
|
|
}
|
|
|
|
|
var id = /^(\.\/|\.\.\/)/.test(args[0]) ? path.resolve(args[0]) : args[0];
|
|
|
|
|
try {
|
|
|
|
|
var module = require(id);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (e.code !== "MODULE_NOT_FOUND") { throw e; }
|
|
|
|
|
|
|
|
|
|
abort("Can't load module \"" + id + "\".");
|
|
|
|
|
}
|
|
|
|
|
options.plugins.push(module);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "-v":
|
|
|
|
|
case "--version":
|
|
|
|
|
printVersion();
|
|
|
|
|