use of org.kohsuke.args4j.ParserProperties in project es6draft by anba.
the class Repl method parseOptions.
private static void parseOptions(Options options, String[] args) {
ParserProperties properties = ParserProperties.defaults().withUsageWidth(128);
CmdLineParser parser = new CmdLineParser(options, properties);
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
System.err.println(e.getMessage());
System.err.println(getUsageString(parser, false));
System.exit(1);
}
if (options.showVersion) {
System.out.println(getVersionString());
System.exit(0);
}
if (options.showHelp) {
System.out.println(getUsageString(parser, false));
System.exit(0);
}
if (options.showExtendedHelp) {
System.out.println(getUsageString(parser, true));
System.exit(0);
}
if (options.printCode || options.printCodeWithTypes || options.debugInfo) {
// Disable interpreter when bytecode is requested
options.noInterpreter = true;
}
if (options.fileName != null) {
// Execute as last script
if (options.fileName.toString().equals("-")) {
// "-" is a short-hand to request reading from System.in
if (System.console() == null) {
// System.in is not interactive
options.evalScripts.add(new EvalString(read(System.in)));
} else {
options.interactive = true;
}
} else {
options.evalScripts.add(new EvalPath(options.fileName, EvalPath.Type.Script));
}
}
if (options.evalScripts.isEmpty()) {
// Default to interactive mode when no files or expressions were set
options.interactive = true;
}
}
Aggregations