*
* @return an options parser.
*/
@SuppressWarnings("static-access")
private static synchronized Options buildOptions() {
Options options = new Options();
options.addOption(OptionBuilder.hasArg().withArgName("path").withDescription("Specify where to find the class files - must be first argument").create("classpath"));
options.addOption(OptionBuilder.withLongOpt("classpath").hasArg().withArgName("path").withDescription("Aliases for '-classpath'").create("cp"));
options.addOption(
OptionBuilder.withLongOpt("define").
withDescription("define a system property").
hasArg(true).
withArgName("name=value").
create('D'));
options.addOption(
OptionBuilder.withLongOpt("disableopt").
withDescription("disables one or all optimization elements. " +
"optlist can be a comma separated list with the elements: " +
"all (disables all optimizations), " +
"int (disable any int based optimizations)").
hasArg(true).
withArgName("optlist").
create());
options.addOption(
OptionBuilder.hasArg(false)
.withDescription("usage information")
.withLongOpt("help")
.create('h'));
options.addOption(
OptionBuilder.hasArg(false)
.withDescription("debug mode will print out full stack traces")
.withLongOpt("debug")
.create('d'));
options.addOption(
OptionBuilder.hasArg(false)
.withDescription("display the Groovy and JVM versions")
.withLongOpt("version")
.create('v'));
options.addOption(
OptionBuilder.withArgName("charset")
.hasArg()
.withDescription("specify the encoding of the files")
.withLongOpt("encoding")
.create('c'));
options.addOption(
OptionBuilder.withArgName("script")
.hasArg()
.withDescription("specify a command line script")
.create('e'));
options.addOption(
OptionBuilder.withArgName("extension")
.hasOptionalArg()
.withDescription("modify files in place; create backup if extension is given (e.g. \'.bak\')")
.create('i'));
options.addOption(
OptionBuilder.hasArg(false)
.withDescription("process files line by line using implicit 'line' variable")
.create('n'));
options.addOption(
OptionBuilder.hasArg(false)
.withDescription("process files line by line and print result (see also -n)")
.create('p'));
options.addOption(
OptionBuilder.withArgName("port")
.hasOptionalArg()
.withDescription("listen on a port and process inbound lines (default: 1960)")
.create('l'));
options.addOption(
OptionBuilder.withArgName("splitPattern")
.hasOptionalArg()
.withDescription("split lines using splitPattern (default '\\s') using implicit 'split' variable")
.withLongOpt("autosplit")
.create('a'));