Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Factory
groovy18
groovy-commons-cli-1.3.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File groovy-commons-cli-1.3.patch of Package groovy18
diff --git a/src/main/groovy/ui/GroovyMain.java b/src/main/groovy/ui/GroovyMain.java index 245c306..e14e617 100644 --- a/src/main/groovy/ui/GroovyMain.java +++ b/src/main/groovy/ui/GroovyMain.java @@ -31,10 +31,10 @@ import java.util.List; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; -import org.apache.commons.cli.PosixParser; +import org.apache.commons.cli.DefaultParser; import org.codehaus.groovy.control.CompilationFailedException; import org.codehaus.groovy.control.CompilerConfiguration; import org.codehaus.groovy.runtime.InvokerHelper; @@ -154,7 +154,7 @@ public class GroovyMain { * @throws ParseException if there was a problem. */ private static CommandLine parseCommandLine(Options options, String[] args) throws ParseException { - CommandLineParser parser = new PosixParser(); + CommandLineParser parser = new DefaultParser(); return parser.parse(options, args, true); } @@ -166,74 +166,74 @@ public class GroovyMain { @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(Option.builder("classpath").hasArg().argName("path").desc("Specify where to find the class files - must be first argument").build()); + options.addOption(Option.builder("cp").longOpt("classpath").hasArg().argName("path").desc("Aliases for '-classpath'").build()); options.addOption( - OptionBuilder.withLongOpt("define"). - withDescription("define a system property"). + Option.builder("D").longOpt("define"). + desc("define a system property"). hasArg(true). - withArgName("name=value"). - create('D')); + argName("name=value"). + build()); 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)"). + Option.builder().longOpt("disableopt"). + desc("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()); + argName("optlist"). + build()); options.addOption( - OptionBuilder.hasArg(false) - .withDescription("usage information") - .withLongOpt("help") - .create('h')); + Option.builder("h").hasArg(false) + .desc("usage information") + .longOpt("help") + .build()); options.addOption( - OptionBuilder.hasArg(false) - .withDescription("debug mode will print out full stack traces") - .withLongOpt("debug") - .create('d')); + Option.builder("d").hasArg(false) + .desc("debug mode will print out full stack traces") + .longOpt("debug") + .build()); options.addOption( - OptionBuilder.hasArg(false) - .withDescription("display the Groovy and JVM versions") - .withLongOpt("version") - .create('v')); + Option.builder("v").hasArg(false) + .desc("display the Groovy and JVM versions") + .longOpt("version") + .build()); options.addOption( - OptionBuilder.withArgName("charset") + Option.builder("c").argName("charset") .hasArg() - .withDescription("specify the encoding of the files") - .withLongOpt("encoding") - .create('c')); + .desc("specify the encoding of the files") + .longOpt("encoding") + .build()); options.addOption( - OptionBuilder.withArgName("script") + Option.builder("e").argName("script") .hasArg() - .withDescription("specify a command line script") - .create('e')); + .desc("specify a command line script") + .build()); options.addOption( - OptionBuilder.withArgName("extension") - .hasOptionalArg() - .withDescription("modify files in place; create backup if extension is given (e.g. \'.bak\')") - .create('i')); + Option.builder("i").argName("extension") + .optionalArg(true) + .desc("modify files in place; create backup if extension is given (e.g. \'.bak\')") + .build()); options.addOption( - OptionBuilder.hasArg(false) - .withDescription("process files line by line using implicit 'line' variable") - .create('n')); + Option.builder("n").hasArg(false) + .desc("process files line by line using implicit 'line' variable") + .build()); options.addOption( - OptionBuilder.hasArg(false) - .withDescription("process files line by line and print result (see also -n)") - .create('p')); + Option.builder("p").hasArg(false) + .desc("process files line by line and print result (see also -n)") + .build()); options.addOption( - OptionBuilder.withArgName("port") - .hasOptionalArg() - .withDescription("listen on a port and process inbound lines (default: 1960)") - .create('l')); + Option.builder("l").argName("port") + .optionalArg(true) + .desc("listen on a port and process inbound lines (default: 1960)") + .build()); options.addOption( - OptionBuilder.withArgName("splitPattern") - .hasOptionalArg() - .withDescription("split lines using splitPattern (default '\\s') using implicit 'split' variable") - .withLongOpt("autosplit") - .create('a')); + Option.builder("a").argName("splitPattern") + .optionalArg(true) + .desc("split lines using splitPattern (default '\\s') using implicit 'split' variable") + .longOpt("autosplit") + .build()); return options; } diff --git a/src/main/groovy/ui/InteractiveShell.java b/src/main/groovy/ui/InteractiveShell.java index bbaa86f..72ea02c 100644 --- a/src/main/groovy/ui/InteractiveShell.java +++ b/src/main/groovy/ui/InteractiveShell.java @@ -43,8 +43,8 @@ import java.util.Set; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.OptionBuilder; -import org.apache.commons.cli.PosixParser; +import org.apache.commons.cli.DefaultParser; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.HelpFormatter; @@ -114,13 +114,13 @@ public class InteractiveShell Options options = new Options(); - options.addOption(OptionBuilder.withLongOpt("help") - .withDescription(MESSAGES.getMessage("cli.option.help.description")) - .create('h')); + options.addOption(Option.builder("h").longOpt("help") + .desc(MESSAGES.getMessage("cli.option.help.description")) + .build()); - options.addOption(OptionBuilder.withLongOpt("version") - .withDescription(MESSAGES.getMessage("cli.option.version.description")) - .create('V')); + options.addOption(Option.builder("V").longOpt("version") + .desc(MESSAGES.getMessage("cli.option.version.description")) + .build()); // // TODO: Add more options, maybe even add an option to prime the buffer from a URL or File? @@ -131,7 +131,7 @@ public class InteractiveShell // Same problem with commons-cli 1.0 and 1.1 // - CommandLineParser parser = new PosixParser(); + CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args, true); String[] lineargs = line.getArgs(); diff --git a/src/main/groovy/util/CliBuilder.groovy b/src/main/groovy/util/CliBuilder.groovy index b126eaf..e57bfdf 100644 --- a/src/main/groovy/util/CliBuilder.groovy +++ b/src/main/groovy/util/CliBuilder.groovy @@ -121,8 +121,8 @@ import org.codehaus.groovy.runtime.InvokerHelper * import org.apache.commons.cli.* * ... as before ... * cli << new Option('q', false, 'If used as the first parameter disables .curlrc') - * cli << OptionBuilder.withLongOpt('url').hasArg().withArgName('URL'). - * withDescription('Set URL to work with').create() + * cli << Option.builder().longOpt('url').hasArg().argName('URL'). + * desc('Set URL to work with').build() * ... * </pre> * @@ -182,6 +182,8 @@ class CliBuilder { /** * To change from the default PosixParser to the GnuParser, set this to false. Ignored if the parser is explicitly set. + * + * @deprecated Both PosixParser and GnuParser are deprecated now in commons-cli 1.3, DefaultParser should be used instead. */ boolean posix = true @@ -248,13 +250,13 @@ class CliBuilder { } /** - * Make options accessible from command line args with parser (default: Posix). + * Make options accessible from command line args with parser (default: DefaultParser). * Returns null on bad command lines after displaying usage message. */ OptionAccessor parse(args) { if (expandArgumentFiles) args = expandArgumentFiles(args) if (!parser) { - parser = posix ? new PosixParser() : new GnuParser() + parser = new DefaultParser() } try { return new OptionAccessor(parser.parse(options, args as String[], stopAtNonOption)) @@ -281,7 +283,7 @@ class CliBuilder { Option option(shortname, Map details, info) { Option option if (shortname == '_') { - option = OptionBuilder.withDescription(info).withLongOpt(details.longOpt).create() + option = Option.builder().desc(info).longOpt(details.longOpt).build() details.remove('longOpt') } else { option = new Option(shortname, info) diff --git a/src/main/org/codehaus/groovy/ant/Groovyc.java b/src/main/org/codehaus/groovy/ant/Groovyc.java index dc2dd14..2e3a076 100644 --- a/src/main/org/codehaus/groovy/ant/Groovyc.java +++ b/src/main/org/codehaus/groovy/ant/Groovyc.java @@ -19,7 +19,7 @@ import groovy.lang.GroovyClassLoader; import groovy.lang.GroovyResourceLoader; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; -import org.apache.commons.cli.PosixParser; +import org.apache.commons.cli.DefaultParser; import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; @@ -933,7 +933,7 @@ public class Groovyc extends MatchingTask { try { Options options = FileSystemCompiler.createCompilationOptions(); - PosixParser cliParser = new PosixParser(); + DefaultParser cliParser = new DefaultParser(); CommandLine cli; cli = cliParser.parse(options, commandLine); diff --git a/src/main/org/codehaus/groovy/antlr/java/Java2GroovyMain.java b/src/main/org/codehaus/groovy/antlr/java/Java2GroovyMain.java index 37f3276..b95eb64 100644 --- a/src/main/org/codehaus/groovy/antlr/java/Java2GroovyMain.java +++ b/src/main/org/codehaus/groovy/antlr/java/Java2GroovyMain.java @@ -27,7 +27,7 @@ import java.util.List; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; -import org.apache.commons.cli.PosixParser; +import org.apache.commons.cli.DefaultParser; import org.codehaus.groovy.antlr.AntlrASTProcessor; import org.codehaus.groovy.antlr.SourceBuffer; import org.codehaus.groovy.antlr.UnicodeEscapingReader; @@ -43,7 +43,7 @@ public class Java2GroovyMain { public static void main(String[] args) { try{ Options options = new Options(); - PosixParser cliParser = new PosixParser(); + DefaultParser cliParser = new DefaultParser(); CommandLine cli = cliParser.parse(options, args); String[] filenames = cli.getArgs(); if( filenames.length == 0 ) { diff --git a/src/main/org/codehaus/groovy/tools/FileSystemCompiler.java b/src/main/org/codehaus/groovy/tools/FileSystemCompiler.java index ade2808..cd8d960 100644 --- a/src/main/org/codehaus/groovy/tools/FileSystemCompiler.java +++ b/src/main/org/codehaus/groovy/tools/FileSystemCompiler.java @@ -115,7 +115,7 @@ public class FileSystemCompiler { public static void commandLineCompile(String[] args, boolean lookupUnnamedFiles) throws Exception { Options options = createCompilationOptions(); - PosixParser cliParser = new PosixParser(); + DefaultParser cliParser = new DefaultParser(); CommandLine cli; cli = cliParser.parse(options, args); @@ -294,30 +294,29 @@ public class FileSystemCompiler { 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("sourcepath").hasArg().withArgName("path").withDescription("Specify where to find the source files").create()); - options.addOption(OptionBuilder.withLongOpt("temp").hasArg().withArgName("temp").withDescription("Specify temporary directory").create()); - options.addOption(OptionBuilder.withLongOpt("encoding").hasArg().withArgName("encoding").withDescription("Specify the encoding of the user class files").create()); - options.addOption(OptionBuilder.hasArg().withDescription("Specify where to place generated class files").create('d')); -// options.addOption(OptionBuilder.withLongOpt("strict").withDescription("Turn on strict type safety.").create('s')); - options.addOption(OptionBuilder.withLongOpt("help").withDescription("Print a synopsis of standard options").create('h')); - options.addOption(OptionBuilder.withLongOpt("version").withDescription("Print the version").create('v')); - options.addOption(OptionBuilder.withLongOpt("exception").withDescription("Print stack trace on error").create('e')); - options.addOption(OptionBuilder.withLongOpt("jointCompilation").withDescription("Attach javac compiler to compile .java files").create('j')); - options.addOption(OptionBuilder.withLongOpt("baseScript").hasArg().withArgName("class").withDescription("Base class name for scripts (must derive from Script)").create('b')); + options.addOption(Option.builder("classpath").hasArg().argName("path").desc("Specify where to find the class files - must be first argument").build()); + options.addOption(Option.builder("cp").longOpt("classpath").hasArg().argName("path").desc("Aliases for '-classpath'").build()); + options.addOption(Option.builder().longOpt("sourcepath").hasArg().argName("path").desc("Specify where to find the source files").build()); + options.addOption(Option.builder().longOpt("temp").hasArg().argName("temp").desc("Specify temporary directory").build()); + options.addOption(Option.builder().longOpt("encoding").hasArg().argName("encoding").desc("Specify the encoding of the user class files").build()); + options.addOption(Option.builder("d").hasArg().desc("Specify where to place generated class files").build()); + options.addOption(Option.builder("h").longOpt("help").desc("Print a synopsis of standard options").build()); + options.addOption(Option.builder("v").longOpt("version").desc("Print the version").build()); + options.addOption(Option.builder("e").longOpt("exception").desc("Print stack trace on error").build()); + options.addOption(Option.builder("j").longOpt("jointCompilation").desc("Attach javac compiler to compile .java files").build()); + options.addOption(Option.builder("b").longOpt("baseScript").hasArg().argName("class").desc("Base class name for scripts (must derive from Script)").build()); options.addOption( - OptionBuilder.withArgName("property=value") - .withValueSeparator() - .hasArgs(2) - .withDescription("name-value pairs to pass to javac") - .create("J")); + Option.builder("J").argName("property=value") + .valueSeparator() + .numberOfArgs(2) + .desc("name-value pairs to pass to javac") + .build()); options.addOption( - OptionBuilder.withArgName("flag") + Option.builder("F").argName("flag") .hasArg() - .withDescription("passed to javac for joint compilation") - .create("F")); + .desc("passed to javac for joint compilation") + .build()); return options; } diff --git a/src/main/org/codehaus/groovy/tools/GrapeMain.groovy b/src/main/org/codehaus/groovy/tools/GrapeMain.groovy index fd9765c..db29526 100644 --- a/src/main/org/codehaus/groovy/tools/GrapeMain.groovy +++ b/src/main/org/codehaus/groovy/tools/GrapeMain.groovy @@ -109,26 +109,26 @@ list = {arg, cmd -> resolve = {arg, cmd -> Options options = new Options(); options.addOption( - OptionBuilder.hasArg(false) - .withLongOpt("ant") - .create('a') + Option.builder("a").hasArg(false) + .longOpt("ant") + .build() ); options.addOption( - OptionBuilder.hasArg(false) - .withLongOpt("dos") - .create('d') + Option.builder("d").hasArg(false) + .longOpt("dos") + .build() ); options.addOption( - OptionBuilder.hasArg(false) - .withLongOpt("shell") - .create('s') + Option.builder("s").hasArg(false) + .longOpt("shell") + .build() ); options.addOption( - OptionBuilder.hasArg(false) - .withLongOpt("ivy") - .create('i') + Option.builder("i").hasArg(false) + .longOpt("ivy") + .build() ); - CommandLine cmd2 = new PosixParser().parse(options, arg[1..-1] as String[], true); + CommandLine cmd2 = new DefaultParser().parse(options, arg[1..-1] as String[], true); arg = cmd2.args // set the instance so we can re-set the logger @@ -221,58 +221,58 @@ def commands = [ Options options = new Options(); options.addOption( - OptionBuilder.withLongOpt("define") - .withDescription("define a system property") + Option.builder("D").longOpt("define") + .desc("define a system property") .hasArg(true) - .withArgName("name=value") - .create('D') + .argName("name=value") + .build() ); options.addOption( - OptionBuilder.hasArg(false) - .withDescription("usage information") - .withLongOpt("help") - .create('h') + Option.builder("h").hasArg(false) + .desc("usage information") + .longOpt("help") + .build() ); // Logging Level Options options.addOptionGroup( new OptionGroup().addOption( - OptionBuilder.hasArg(false) - .withDescription("Log level 0 - only errors") - .withLongOpt("quiet") - .create('q')) + Option.builder("q").hasArg(false) + .desc("Log level 0 - only errors") + .longOpt("quiet") + .build()) .addOption( - OptionBuilder.hasArg(false) - .withDescription("Log level 1 - errors and warnings") - .withLongOpt("warn") - .create('w')) + Option.builder("w").hasArg(false) + .desc("Log level 1 - errors and warnings") + .longOpt("warn") + .build()) .addOption( - OptionBuilder.hasArg(false) - .withDescription("Log level 2 - info") - .withLongOpt("info") - .create('i')) + Option.builder("i").hasArg(false) + .desc("Log level 2 - info") + .longOpt("info") + .build()) .addOption( - OptionBuilder.hasArg(false) - .withDescription("Log level 3 - verbose") - .withLongOpt("verbose") - .create('V')) + Option.builder("V").hasArg(false) + .desc("Log level 3 - verbose") + .longOpt("verbose") + .build()) .addOption( - OptionBuilder.hasArg(false) - .withDescription("Log level 4 - debug") - .withLongOpt("debug") - .create('d')) + Option.builder("d").hasArg(false) + .desc("Log level 4 - debug") + .longOpt("debug") + .build()) ) options.addOption( - OptionBuilder.hasArg(false) - .withDescription("display the Groovy and JVM versions") - .withLongOpt("version") - .create('v') + Option.builder("v").hasArg(false) + .desc("display the Groovy and JVM versions") + .longOpt("version") + .build() ); -CommandLine cmd = new PosixParser().parse(options, args, true); +CommandLine cmd = new DefaultParser().parse(options, args, true); grapeHelp = { int spacesLen = commands.keySet().max {it.length()}.length() + 3 diff --git a/src/test/groovy/util/CliBuilderTest.groovy b/src/test/groovy/util/CliBuilderTest.groovy index cbd7bd1..d67de50 100644 --- a/src/test/groovy/util/CliBuilderTest.groovy +++ b/src/test/groovy/util/CliBuilderTest.groovy @@ -16,7 +16,6 @@ package groovy.util import org.apache.commons.cli.GnuParser import org.apache.commons.cli.Option -import org.apache.commons.cli.OptionBuilder import org.apache.commons.cli.PosixParser import org.apache.commons.cli.BasicParser @@ -175,7 +174,7 @@ usage: groovy } private void checkLongOptsOnly_nonOptionShouldStopArgProcessing(CliBuilder cli) { - def anOption = OptionBuilder.withLongOpt('anOption').hasArg().withDescription('An option.').create() + def anOption = Option.builder().longOpt('anOption').hasArg().desc('An option.').build() cli.options.addOption(anOption) def options = cli.parse(['-v', '--anOption', 'something']) // no options should be found @@ -203,7 +202,7 @@ usage: groovy private void checkLongAndShortOpts_allOptionsValid(parser) { def cli = new CliBuilder(parser: parser) - def anOption = OptionBuilder.withLongOpt('anOption').hasArg().withDescription('An option.').create() + def anOption = Option.builder().longOpt('anOption').hasArg().desc('An option.').build() cli.options.addOption(anOption) cli.v(longOpt: 'verbose', 'verbose mode') def options = cli.parse(['-v', '--anOption', 'something'])
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor