bin/pegjs: Order options in a switch statement alphabetically

redux
David Majda 8 years ago
parent ff330a0d4b
commit 0a2217d3da

@ -120,22 +120,18 @@ var options = {
while (args.length > 0 && isOption(args[0])) { while (args.length > 0 && isOption(args[0])) {
switch (args[0]) { switch (args[0]) {
case "-o": case "--allowed-start-rules":
case "--output":
nextArg(); nextArg();
if (args.length === 0) { if (args.length === 0) {
abort("Missing parameter of the -o/--output option."); abort("Missing parameter of the -e/--allowed-start-rules option.");
} }
outputFile = args[0]; options.allowedStartRules = args[0]
.split(",")
.map(trim);
break; break;
case "-e": case "--cache":
case "--export-var": options.cache = true;
nextArg();
if (args.length === 0) {
abort("Missing parameter of the -e/--export-var option.");
}
options.exportVar = args[0];
break; break;
case "-d": case "-d":
@ -152,22 +148,40 @@ while (args.length > 0 && isOption(args[0])) {
} }
break; break;
case "--cache": case "-e":
options.cache = true; case "--export-var":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the -e/--export-var option.");
}
options.exportVar = args[0];
break; break;
case "--allowed-start-rules": case "--extra-options":
nextArg(); nextArg();
if (args.length === 0) { if (args.length === 0) {
abort("Missing parameter of the -e/--allowed-start-rules option."); abort("Missing parameter of the --extra-options option.");
} }
options.allowedStartRules = args[0] addExtraOptions(options, args[0]);
.split(",")
.map(trim);
break; break;
case "--trace": case "--extra-options-file":
options.trace = true; nextArg();
if (args.length === 0) {
abort("Missing parameter of the --extra-options-file option.");
}
try {
var json = fs.readFileSync(args[0]);
} catch(e) {
abort("Can't read from file \"" + args[0] + "\".");
}
addExtraOptions(options, json);
break;
case "-h":
case "--help":
printHelp();
exitSuccess();
break; break;
case "-O": case "-O":
@ -182,6 +196,15 @@ while (args.length > 0 && isOption(args[0])) {
options.optimize = args[0]; options.optimize = args[0];
break; break;
case "-o":
case "--output":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the -o/--output option.");
}
outputFile = args[0];
break;
case "--plugin": case "--plugin":
nextArg(); nextArg();
if (args.length === 0) { if (args.length === 0) {
@ -199,25 +222,8 @@ while (args.length > 0 && isOption(args[0])) {
options.plugins.push(mod); options.plugins.push(mod);
break; break;
case "--extra-options": case "--trace":
nextArg(); options.trace = true;
if (args.length === 0) {
abort("Missing parameter of the --extra-options option.");
}
addExtraOptions(options, args[0]);
break;
case "--extra-options-file":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the --extra-options-file option.");
}
try {
var json = fs.readFileSync(args[0]);
} catch(e) {
abort("Can't read from file \"" + args[0] + "\".");
}
addExtraOptions(options, json);
break; break;
case "-v": case "-v":
@ -226,12 +232,6 @@ while (args.length > 0 && isOption(args[0])) {
exitSuccess(); exitSuccess();
break; break;
case "-h":
case "--help":
printHelp();
exitSuccess();
break;
case "--": case "--":
nextArg(); nextArg();
break; break;

Loading…
Cancel
Save