private void initConfigFromFlags(String[] args, PrintStream err) {
List<String> processedArgs = processArgs(args);
CmdLineParser parser = new CmdLineParser(flags);
Flags.warningGuardSpec.clear();
isConfigValid = true;
try {
parser.parseArgument(processedArgs.toArray(new String[] {}));
// For contains --flagfile flag
if (!flags.flag_file.equals("")) {
processFlagFile(err);
}
} catch (CmdLineException e) {
err.println(e.getMessage());
isConfigValid = false;
} catch (IOException ioErr) {
err.println("ERROR - " + flags.flag_file + " read error.");
isConfigValid = false;
}
if (flags.version) {
ResourceBundle config = ResourceBundle.getBundle(configResource);
err.println(
"Closure Compiler (http://code.google.com/closure/compiler)\n" +
"Version: " + config.getString("compiler.version") + "\n" +
"Built on: " + config.getString("compiler.date"));
err.flush();
}
if (!isConfigValid || flags.display_help) {
isConfigValid = false;
parser.printUsage(err);
} else {
getCommandLineConfig()
.setPrintTree(flags.print_tree)
.setPrintAst(flags.print_ast)
.setPrintPassGraph(flags.print_pass_graph)