static void processArgs(String[] args,
PrintStream out) {
Options options = buildOptions();
try {
CommandLine cmd = parseCommandLine(options, args);
if (cmd.hasOption('h")) {
printHelp(out, options);
} else if (cmd.hasOption('v")) {
String version = InvokerHelper.getVersion();
out.println("Groovy Version: " + version + " JVM: " + System.getProperty("java.version"));
} else {
// If we fail, then exit with an error so scripting frameworks can catch it
// TODO: pass printstream(s) down through process
if (!process(cmd)) {
System.exit(1);
}
}
} catch (ParseException pe) {
out.println("error: " + pe.getMessage());
printHelp(out, options);
}
}
|