diff --git a/bin/pegjs b/bin/pegjs index 3250367..084aece 100755 --- a/bin/pegjs +++ b/bin/pegjs @@ -120,22 +120,18 @@ var options = { while (args.length > 0 && isOption(args[0])) { switch (args[0]) { - case "-o": - case "--output": + case "--allowed-start-rules": nextArg(); 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; - case "-e": - case "--export-var": - nextArg(); - if (args.length === 0) { - abort("Missing parameter of the -e/--export-var option."); - } - options.exportVar = args[0]; + case "--cache": + options.cache = true; break; case "-d": @@ -152,22 +148,40 @@ while (args.length > 0 && isOption(args[0])) { } break; - case "--cache": - options.cache = true; + case "-e": + case "--export-var": + nextArg(); + if (args.length === 0) { + abort("Missing parameter of the -e/--export-var option."); + } + options.exportVar = args[0]; break; - case "--allowed-start-rules": + case "--extra-options": nextArg(); 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] - .split(",") - .map(trim); + addExtraOptions(options, args[0]); break; - case "--trace": - options.trace = true; + 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; + + case "-h": + case "--help": + printHelp(); + exitSuccess(); break; case "-O": @@ -182,6 +196,15 @@ while (args.length > 0 && isOption(args[0])) { options.optimize = args[0]; break; + case "-o": + case "--output": + nextArg(); + if (args.length === 0) { + abort("Missing parameter of the -o/--output option."); + } + outputFile = args[0]; + break; + case "--plugin": nextArg(); if (args.length === 0) { @@ -199,25 +222,8 @@ while (args.length > 0 && isOption(args[0])) { options.plugins.push(mod); break; - case "--extra-options": - nextArg(); - 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); + case "--trace": + options.trace = true; break; case "-v": @@ -226,12 +232,6 @@ while (args.length > 0 && isOption(args[0])) { exitSuccess(); break; - case "-h": - case "--help": - printHelp(); - exitSuccess(); - break; - case "--": nextArg(); break;