[jira] [Commented] (GROOVY-9432) ClassNotFoundException when attempting to use Picocli via Grapes
[ https://issues.apache.org/jira/browse/GROOVY-9432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17097038#comment-17097038 ] Remko Popma commented on GROOVY-9432: - Reworded as per Paul's suggestion. I am not sure why {{@GrabConfig(systemClassLoader=true)}} is needed :-) so I will leave that question to Paul. > ClassNotFoundException when attempting to use Picocli via Grapes > > > Key: GROOVY-9432 > URL: https://issues.apache.org/jira/browse/GROOVY-9432 > Project: Groovy > Issue Type: Bug > Components: Grape >Affects Versions: 3.0.0, 3.0.1 > Environment: Reproduced under both macOS (Groovy 3.0.1 installed > manually and via MacPorts) and Debian (Groovy installed via SDKMAN). >Reporter: Marc Simpson >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4 > > Attachments: image-2020-03-03-14-30-10-210.png > > > (Issue originally raised as: https://github.com/remkop/picocli/issues/970) > Consider the following minimal script: > {noformat} > @Grab('info.picocli:picocli:4.2.0') > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder() > {noformat} > Under Groovy 2.5.9, this runs without error; with 3.0.1, however, I see: > {noformat} > $ groovy cli.groovy > Caught: java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > at cli.run(cli.groovy:4) > at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > Caused by: java.lang.ClassNotFoundException: > picocli.CommandLine$ParameterException > ... 4 more > {noformat} > The jar is definitely downloaded to {{~/.groovy/grapes}} and both versions of > Groovy output > {noformat} > Resolving dependency: info.picocli#picocli;4.2.0 {default=[default]} > Preparing to download artifact info.picocli#picocli;4.2.0!picocli.jar > {noformat} > when {{-Dgroovy.grape.report.downloads=true}} is supplied. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Resolved] (GROOVY-9432) ClassNotFoundException when attempting to use Picocli via Grapes
[ https://issues.apache.org/jira/browse/GROOVY-9432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Remko Popma resolved GROOVY-9432. - Resolution: Fixed > ClassNotFoundException when attempting to use Picocli via Grapes > > > Key: GROOVY-9432 > URL: https://issues.apache.org/jira/browse/GROOVY-9432 > Project: Groovy > Issue Type: Bug > Components: Grape >Affects Versions: 3.0.0, 3.0.1 > Environment: Reproduced under both macOS (Groovy 3.0.1 installed > manually and via MacPorts) and Debian (Groovy installed via SDKMAN). >Reporter: Marc Simpson >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4 > > Attachments: image-2020-03-03-14-30-10-210.png > > > (Issue originally raised as: https://github.com/remkop/picocli/issues/970) > Consider the following minimal script: > {noformat} > @Grab('info.picocli:picocli:4.2.0') > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder() > {noformat} > Under Groovy 2.5.9, this runs without error; with 3.0.1, however, I see: > {noformat} > $ groovy cli.groovy > Caught: java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > at cli.run(cli.groovy:4) > at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > Caused by: java.lang.ClassNotFoundException: > picocli.CommandLine$ParameterException > ... 4 more > {noformat} > The jar is definitely downloaded to {{~/.groovy/grapes}} and both versions of > Groovy output > {noformat} > Resolving dependency: info.picocli#picocli;4.2.0 {default=[default]} > Preparing to download artifact info.picocli#picocli;4.2.0!picocli.jar > {noformat} > when {{-Dgroovy.grape.report.downloads=true}} is supplied. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9528) CLIBuilder: "error: Missing required options" when unknown options are provided
[ https://issues.apache.org/jira/browse/GROOVY-9528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17097024#comment-17097024 ] Paul King commented on GROOVY-9528: --- Ah, I forgot to push. Sorry for the noise. All good now. > CLIBuilder: "error: Missing required options" when unknown options are > provided > --- > > Key: GROOVY-9528 > URL: https://issues.apache.org/jira/browse/GROOVY-9528 > Project: Groovy > Issue Type: Bug > Components: command line processing >Affects Versions: 3.0.2 > Environment: Linux/Windows >Reporter: Dirk Heinrichs >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4, 2.5.12 > > > When passing an additional option to a script that doesn't know about this > option, I get an error message about "missing required options", listing all > required options that follow the unkown option. > The following example code reproduces the issue: > {code:java} > @Grab('info.picocli:picocli-groovy:4.2.0') > @GrabConfig(systemClassLoader=true) > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder(name: 'cliTest.groovy') > cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show > usage information') > cli.a(type: String, longOpt: 'optA', required: true, args: 1, 'Option a > (required)') > cli.b(type: String, longOpt: 'optB', required: true, args: 1, 'Option b > (required)') > // NOTE: No "-c|--optC" here > cli.d(type: String, longOpt: 'optD', required: true, args: 1, 'Option d > (required)') > cli.e(type: String, longOpt: 'optE', required: true, args: 1, 'Option e > (required)') > cli.f(type: String, longOpt: 'optF', required: false, args: 1, 'Option f > (optional)') > def opts = cli.parse(args) > opts || System.exit(1) > if(opts.h) { > cli.usage() > System.exit(0) > }{code} > When invoked with an additional option, '-c C' for example, it produces the > following, misleading output: > {code:java} > % ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy -a A -b B -c C -d D -e E > error: Missing required options [--optD=PARAM, --optE=PARAM] > Usage: cliTest.groovy [-h] -a=PARAM -b=PARAM -d=PARAM -e=PARAM [-f=PARAM] > -a, --optA=PARAM Option a (required) > -b, --optB=PARAM Option b (required) > -d, --optD=PARAM Option d (required) > -e, --optE=PARAM Option e (required) > -f, --optF=PARAM Option f (optional) > -h, --help Show usage information{code} > The list of missing options varies depending on where "-c C" is inserted. > There's no error when it's the last one. > I would expect it to either ignore the addtional option in all cases or emit > an error message about an unknown option. But in no case should it error out > because of missing required options when there are none missing. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9432) ClassNotFoundException when attempting to use Picocli via Grapes
[ https://issues.apache.org/jira/browse/GROOVY-9432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17097018#comment-17097018 ] Marc Simpson commented on GROOVY-9432: -- This looks good to me. One question: Should the documentation explain why {code:groovy} @GrabConfig(systemClassLoader=true) {code} is necessary? > ClassNotFoundException when attempting to use Picocli via Grapes > > > Key: GROOVY-9432 > URL: https://issues.apache.org/jira/browse/GROOVY-9432 > Project: Groovy > Issue Type: Bug > Components: Grape >Affects Versions: 3.0.0, 3.0.1 > Environment: Reproduced under both macOS (Groovy 3.0.1 installed > manually and via MacPorts) and Debian (Groovy installed via SDKMAN). >Reporter: Marc Simpson >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4 > > Attachments: image-2020-03-03-14-30-10-210.png > > > (Issue originally raised as: https://github.com/remkop/picocli/issues/970) > Consider the following minimal script: > {noformat} > @Grab('info.picocli:picocli:4.2.0') > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder() > {noformat} > Under Groovy 2.5.9, this runs without error; with 3.0.1, however, I see: > {noformat} > $ groovy cli.groovy > Caught: java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > at cli.run(cli.groovy:4) > at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > Caused by: java.lang.ClassNotFoundException: > picocli.CommandLine$ParameterException > ... 4 more > {noformat} > The jar is definitely downloaded to {{~/.groovy/grapes}} and both versions of > Groovy output > {noformat} > Resolving dependency: info.picocli#picocli;4.2.0 {default=[default]} > Preparing to download artifact info.picocli#picocli;4.2.0!picocli.jar > {noformat} > when {{-Dgroovy.grape.report.downloads=true}} is supplied. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9528) CLIBuilder: "error: Missing required options" when unknown options are provided
[ https://issues.apache.org/jira/browse/GROOVY-9528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17097019#comment-17097019 ] Paul King commented on GROOVY-9528: --- It should have already been there? > CLIBuilder: "error: Missing required options" when unknown options are > provided > --- > > Key: GROOVY-9528 > URL: https://issues.apache.org/jira/browse/GROOVY-9528 > Project: Groovy > Issue Type: Bug > Components: command line processing >Affects Versions: 3.0.2 > Environment: Linux/Windows >Reporter: Dirk Heinrichs >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4, 2.5.12 > > > When passing an additional option to a script that doesn't know about this > option, I get an error message about "missing required options", listing all > required options that follow the unkown option. > The following example code reproduces the issue: > {code:java} > @Grab('info.picocli:picocli-groovy:4.2.0') > @GrabConfig(systemClassLoader=true) > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder(name: 'cliTest.groovy') > cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show > usage information') > cli.a(type: String, longOpt: 'optA', required: true, args: 1, 'Option a > (required)') > cli.b(type: String, longOpt: 'optB', required: true, args: 1, 'Option b > (required)') > // NOTE: No "-c|--optC" here > cli.d(type: String, longOpt: 'optD', required: true, args: 1, 'Option d > (required)') > cli.e(type: String, longOpt: 'optE', required: true, args: 1, 'Option e > (required)') > cli.f(type: String, longOpt: 'optF', required: false, args: 1, 'Option f > (optional)') > def opts = cli.parse(args) > opts || System.exit(1) > if(opts.h) { > cli.usage() > System.exit(0) > }{code} > When invoked with an additional option, '-c C' for example, it produces the > following, misleading output: > {code:java} > % ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy -a A -b B -c C -d D -e E > error: Missing required options [--optD=PARAM, --optE=PARAM] > Usage: cliTest.groovy [-h] -a=PARAM -b=PARAM -d=PARAM -e=PARAM [-f=PARAM] > -a, --optA=PARAM Option a (required) > -b, --optB=PARAM Option b (required) > -d, --optD=PARAM Option d (required) > -e, --optE=PARAM Option e (required) > -f, --optF=PARAM Option f (optional) > -h, --help Show usage information{code} > The list of missing options varies depending on where "-c C" is inserted. > There's no error when it's the last one. > I would expect it to either ignore the addtional option in all cases or emit > an error message about an unknown option. But in no case should it error out > because of missing required options when there are none missing. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Comment Edited] (GROOVY-9432) ClassNotFoundException when attempting to use Picocli via Grapes
[ https://issues.apache.org/jira/browse/GROOVY-9432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17097016#comment-17097016 ] Paul King edited comment on GROOVY-9432 at 4/30/20, 10:13 PM: -- I would consider changing the intro wording. Instead of: {quote}If necessary, you can use the @Grab annotation to control the version of picocli to use in CliBuilder. {quote} Perhaps: {quote}To use a specific version of picocli, add a dependency to that version in your build configuration. If running scripts using a pre-installed version of Groovy, use the @Grab annotation to control the version of picocli to use in CliBuilder. {quote} I would skip GROOVY_2_5_X since we removed the picocli jar only in Groovy 3 (as per GROOVY-9165). In 2_5_X, it comes with a picocli jar, hence no need for the @Grab, and you'd need to first manually remove the pre-installed version before you could swap versions. was (Author: paulk): I would consider changing the intro wording. Instead of: bq. If necessary, you can use the @Grab annotation to control the version of picocli to use in CliBuilder. Perhaps: bq. To use a specific version of picocli, add a dependency to that version in your build configuration. If running scripts using a pre-installed version of Groovy, use the @Grab annotation to control the version of picocli to use in CliBuilder. I would skip GROOVY_2_5_X since we removed the picocli jar only in Groovy 3 (as per GROOVY-9165). In 2_5_X, it comes with a picocli jar, hence no need for the @Grab, and you'd need to first manually remove it before you could swap versions. > ClassNotFoundException when attempting to use Picocli via Grapes > > > Key: GROOVY-9432 > URL: https://issues.apache.org/jira/browse/GROOVY-9432 > Project: Groovy > Issue Type: Bug > Components: Grape >Affects Versions: 3.0.0, 3.0.1 > Environment: Reproduced under both macOS (Groovy 3.0.1 installed > manually and via MacPorts) and Debian (Groovy installed via SDKMAN). >Reporter: Marc Simpson >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4 > > Attachments: image-2020-03-03-14-30-10-210.png > > > (Issue originally raised as: https://github.com/remkop/picocli/issues/970) > Consider the following minimal script: > {noformat} > @Grab('info.picocli:picocli:4.2.0') > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder() > {noformat} > Under Groovy 2.5.9, this runs without error; with 3.0.1, however, I see: > {noformat} > $ groovy cli.groovy > Caught: java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > at cli.run(cli.groovy:4) > at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > Caused by: java.lang.ClassNotFoundException: > picocli.CommandLine$ParameterException > ... 4 more > {noformat} > The jar is definitely downloaded to {{~/.groovy/grapes}} and both versions of > Groovy output > {noformat} > Resolving dependency: info.picocli#picocli;4.2.0 {default=[default]} > Preparing to download artifact info.picocli#picocli;4.2.0!picocli.jar > {noformat} > when {{-Dgroovy.grape.report.downloads=true}} is supplied. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9432) ClassNotFoundException when attempting to use Picocli via Grapes
[ https://issues.apache.org/jira/browse/GROOVY-9432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17097016#comment-17097016 ] Paul King commented on GROOVY-9432: --- I would consider changing the intro wording. Instead of: bq. If necessary, you can use the @Grab annotation to control the version of picocli to use in CliBuilder. Perhaps: bq. To use a specific version of picocli, add a dependency to that version in your build configuration. If running scripts using a pre-installed version of Groovy, use the @Grab annotation to control the version of picocli to use in CliBuilder. I would skip GROOVY_2_5_X since we removed the picocli jar only in Groovy 3 (as per GROOVY-9165). In 2_5_X, it comes with a picocli jar, hence no need for the @Grab, and you'd need to first manually remove it before you could swap versions. > ClassNotFoundException when attempting to use Picocli via Grapes > > > Key: GROOVY-9432 > URL: https://issues.apache.org/jira/browse/GROOVY-9432 > Project: Groovy > Issue Type: Bug > Components: Grape >Affects Versions: 3.0.0, 3.0.1 > Environment: Reproduced under both macOS (Groovy 3.0.1 installed > manually and via MacPorts) and Debian (Groovy installed via SDKMAN). >Reporter: Marc Simpson >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4 > > Attachments: image-2020-03-03-14-30-10-210.png > > > (Issue originally raised as: https://github.com/remkop/picocli/issues/970) > Consider the following minimal script: > {noformat} > @Grab('info.picocli:picocli:4.2.0') > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder() > {noformat} > Under Groovy 2.5.9, this runs without error; with 3.0.1, however, I see: > {noformat} > $ groovy cli.groovy > Caught: java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > at cli.run(cli.groovy:4) > at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > Caused by: java.lang.ClassNotFoundException: > picocli.CommandLine$ParameterException > ... 4 more > {noformat} > The jar is definitely downloaded to {{~/.groovy/grapes}} and both versions of > Groovy output > {noformat} > Resolving dependency: info.picocli#picocli;4.2.0 {default=[default]} > Preparing to download artifact info.picocli#picocli;4.2.0!picocli.jar > {noformat} > when {{-Dgroovy.grape.report.downloads=true}} is supplied. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Updated] (GROOVY-9432) ClassNotFoundException when attempting to use Picocli via Grapes
[ https://issues.apache.org/jira/browse/GROOVY-9432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Remko Popma updated GROOVY-9432: Fix Version/s: 3.0.4 > ClassNotFoundException when attempting to use Picocli via Grapes > > > Key: GROOVY-9432 > URL: https://issues.apache.org/jira/browse/GROOVY-9432 > Project: Groovy > Issue Type: Bug > Components: Grape >Affects Versions: 3.0.0, 3.0.1 > Environment: Reproduced under both macOS (Groovy 3.0.1 installed > manually and via MacPorts) and Debian (Groovy installed via SDKMAN). >Reporter: Marc Simpson >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4 > > Attachments: image-2020-03-03-14-30-10-210.png > > > (Issue originally raised as: https://github.com/remkop/picocli/issues/970) > Consider the following minimal script: > {noformat} > @Grab('info.picocli:picocli:4.2.0') > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder() > {noformat} > Under Groovy 2.5.9, this runs without error; with 3.0.1, however, I see: > {noformat} > $ groovy cli.groovy > Caught: java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > at cli.run(cli.groovy:4) > at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > Caused by: java.lang.ClassNotFoundException: > picocli.CommandLine$ParameterException > ... 4 more > {noformat} > The jar is definitely downloaded to {{~/.groovy/grapes}} and both versions of > Groovy output > {noformat} > Resolving dependency: info.picocli#picocli;4.2.0 {default=[default]} > Preparing to download artifact info.picocli#picocli;4.2.0!picocli.jar > {noformat} > when {{-Dgroovy.grape.report.downloads=true}} is supplied. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Updated] (GROOVY-9531) Improve CliBuilder docs for Groovy 3.0
[ https://issues.apache.org/jira/browse/GROOVY-9531?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Remko Popma updated GROOVY-9531: Fix Version/s: 2.5.12 > Improve CliBuilder docs for Groovy 3.0 > -- > > Key: GROOVY-9531 > URL: https://issues.apache.org/jira/browse/GROOVY-9531 > Project: Groovy > Issue Type: Documentation > Components: command line processing >Affects Versions: 3.0.0, 3.0.1, 3.0.2, 3.0.3 >Reporter: Remko Popma >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4, 2.5.12 > > > The [CliBuilder section|[http://groovy-lang.org/dsls.html#_clibuilder]] of > the Domain-Specific Languages page has some language that is outdated since > the Groovy 3.0 release. > Current: > {quote} > The groovy.util version points to the commons-cli version for backwards > compatibility but will be removed in a future version of Groovy. > {quote} > I propose to change this to: > {quote} > The groovy.util version in Groovy 2.5 points to the commons-cli version for > backwards compatibility but has been removed in Groovy 3.0. > {quote} > -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Updated] (GROOVY-9519) CLIBuilder: Option with "type: Integer, defaultValue '0'" results in Boolean if default value is applied
[ https://issues.apache.org/jira/browse/GROOVY-9519?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Remko Popma updated GROOVY-9519: Fix Version/s: 2.5.12 > CLIBuilder: Option with "type: Integer, defaultValue '0'" results in Boolean > if default value is applied > > > Key: GROOVY-9519 > URL: https://issues.apache.org/jira/browse/GROOVY-9519 > Project: Groovy > Issue Type: Bug > Components: command line processing >Affects Versions: 3.0.2 > Environment: WIndows/Linux >Reporter: Dirk Heinrichs >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4, 2.5.12 > > > When using an option with {{type: Integer}} and {{defaultValue: '0'}} the > resulting variable is of type Boolean if the option is not specified on the > command line. Here's a little Groovy program to demonstrate the issue: > {code:java} > @Grab('info.picocli:picocli-groovy:4.2.0') > @GrabConfig(systemClassLoader=true) > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder(name: 'cliTest.groovy') > cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show > usage information') > cli.i(type: Integer, longOpt: 'intTest', required: false, args: 1, > defaultValue: '0', 'Testing integer with default value 0') > def opts = cli.parse(args) > opts || System.exit(1) > if(opts.h) { > cli.usage() > System.exit(0) > } > println(opts.i.getClass()) > println(opts.i) > // Need to explicitely convert if default value applies > def i = (opts.i instanceof Boolean ? 0 : opts.i) > println(i.getClass()) > println(i){code} > Executing this w/o providing {{-i}} prints: > {code}% ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy > class java.lang.Boolean > false > class java.lang.Integer > 0{code} > But if {{-i}} IS provided (even with the same value as the default), it > correctly prints: > {code}% ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy -i 0 > class java.lang.Integer > 0 > class java.lang.Integer > 0{code} > I would expect the type of {{opts.i}} to be Integer in both cases. > NOTE: I've opened the same for PicoCLI, since I wasn't sure where it belongs. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9528) CLIBuilder: "error: Missing required options" when unknown options are provided
[ https://issues.apache.org/jira/browse/GROOVY-9528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17097012#comment-17097012 ] Remko Popma commented on GROOVY-9528: - I cherry-picked your new test (thanks again for that!) to 2_5_x as well. > CLIBuilder: "error: Missing required options" when unknown options are > provided > --- > > Key: GROOVY-9528 > URL: https://issues.apache.org/jira/browse/GROOVY-9528 > Project: Groovy > Issue Type: Bug > Components: command line processing >Affects Versions: 3.0.2 > Environment: Linux/Windows >Reporter: Dirk Heinrichs >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4, 2.5.12 > > > When passing an additional option to a script that doesn't know about this > option, I get an error message about "missing required options", listing all > required options that follow the unkown option. > The following example code reproduces the issue: > {code:java} > @Grab('info.picocli:picocli-groovy:4.2.0') > @GrabConfig(systemClassLoader=true) > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder(name: 'cliTest.groovy') > cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show > usage information') > cli.a(type: String, longOpt: 'optA', required: true, args: 1, 'Option a > (required)') > cli.b(type: String, longOpt: 'optB', required: true, args: 1, 'Option b > (required)') > // NOTE: No "-c|--optC" here > cli.d(type: String, longOpt: 'optD', required: true, args: 1, 'Option d > (required)') > cli.e(type: String, longOpt: 'optE', required: true, args: 1, 'Option e > (required)') > cli.f(type: String, longOpt: 'optF', required: false, args: 1, 'Option f > (optional)') > def opts = cli.parse(args) > opts || System.exit(1) > if(opts.h) { > cli.usage() > System.exit(0) > }{code} > When invoked with an additional option, '-c C' for example, it produces the > following, misleading output: > {code:java} > % ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy -a A -b B -c C -d D -e E > error: Missing required options [--optD=PARAM, --optE=PARAM] > Usage: cliTest.groovy [-h] -a=PARAM -b=PARAM -d=PARAM -e=PARAM [-f=PARAM] > -a, --optA=PARAM Option a (required) > -b, --optB=PARAM Option b (required) > -d, --optD=PARAM Option d (required) > -e, --optE=PARAM Option e (required) > -f, --optF=PARAM Option f (optional) > -h, --help Show usage information{code} > The list of missing options varies depending on where "-c C" is inserted. > There's no error when it's the last one. > I would expect it to either ignore the addtional option in all cases or emit > an error message about an unknown option. But in no case should it error out > because of missing required options when there are none missing. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9519) CLIBuilder: Option with "type: Integer, defaultValue '0'" results in Boolean if default value is applied
[ https://issues.apache.org/jira/browse/GROOVY-9519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17097009#comment-17097009 ] Remko Popma commented on GROOVY-9519: - Also added to the 2_5_x branch, except for the changes to {{groovy.cli.internal.CliBuilderInternal}} (which does not exist in this branch). > CLIBuilder: Option with "type: Integer, defaultValue '0'" results in Boolean > if default value is applied > > > Key: GROOVY-9519 > URL: https://issues.apache.org/jira/browse/GROOVY-9519 > Project: Groovy > Issue Type: Bug > Components: command line processing >Affects Versions: 3.0.2 > Environment: WIndows/Linux >Reporter: Dirk Heinrichs >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4 > > > When using an option with {{type: Integer}} and {{defaultValue: '0'}} the > resulting variable is of type Boolean if the option is not specified on the > command line. Here's a little Groovy program to demonstrate the issue: > {code:java} > @Grab('info.picocli:picocli-groovy:4.2.0') > @GrabConfig(systemClassLoader=true) > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder(name: 'cliTest.groovy') > cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show > usage information') > cli.i(type: Integer, longOpt: 'intTest', required: false, args: 1, > defaultValue: '0', 'Testing integer with default value 0') > def opts = cli.parse(args) > opts || System.exit(1) > if(opts.h) { > cli.usage() > System.exit(0) > } > println(opts.i.getClass()) > println(opts.i) > // Need to explicitely convert if default value applies > def i = (opts.i instanceof Boolean ? 0 : opts.i) > println(i.getClass()) > println(i){code} > Executing this w/o providing {{-i}} prints: > {code}% ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy > class java.lang.Boolean > false > class java.lang.Integer > 0{code} > But if {{-i}} IS provided (even with the same value as the default), it > correctly prints: > {code}% ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy -i 0 > class java.lang.Integer > 0 > class java.lang.Integer > 0{code} > I would expect the type of {{opts.i}} to be Integer in both cases. > NOTE: I've opened the same for PicoCLI, since I wasn't sure where it belongs. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9432) ClassNotFoundException when attempting to use Picocli via Grapes
[ https://issues.apache.org/jira/browse/GROOVY-9432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17097004#comment-17097004 ] Remko Popma commented on GROOVY-9432: - I am adding the following to the (bottom of the) {{CliBuilder}} section of the [Domain Specific Languages page|http://groovy-lang.org/dsls.html#_clibuilder]. {quote} h4. Controlling the Picocli version If necessary, you can use the {{@Grab}} annotation to control the version of picocli to use in {{CliBuilder}}. {code} @GrabConfig(systemClassLoader=true) @Grab('info.picocli:picocli:4.2.0') import groovy.cli.picocli.CliBuilder def cli = new CliBuilder() {code} {quote} [~marcs]: do you think this is sufficient? [~paulk]: I committed this to the master and 3_0_x branches. Should I also add it to 2_5_x ? > ClassNotFoundException when attempting to use Picocli via Grapes > > > Key: GROOVY-9432 > URL: https://issues.apache.org/jira/browse/GROOVY-9432 > Project: Groovy > Issue Type: Bug > Components: Grape >Affects Versions: 3.0.0, 3.0.1 > Environment: Reproduced under both macOS (Groovy 3.0.1 installed > manually and via MacPorts) and Debian (Groovy installed via SDKMAN). >Reporter: Marc Simpson >Assignee: Remko Popma >Priority: Major > Attachments: image-2020-03-03-14-30-10-210.png > > > (Issue originally raised as: https://github.com/remkop/picocli/issues/970) > Consider the following minimal script: > {noformat} > @Grab('info.picocli:picocli:4.2.0') > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder() > {noformat} > Under Groovy 2.5.9, this runs without error; with 3.0.1, however, I see: > {noformat} > $ groovy cli.groovy > Caught: java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > at cli.run(cli.groovy:4) > at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > Caused by: java.lang.ClassNotFoundException: > picocli.CommandLine$ParameterException > ... 4 more > {noformat} > The jar is definitely downloaded to {{~/.groovy/grapes}} and both versions of > Groovy output > {noformat} > Resolving dependency: info.picocli#picocli;4.2.0 {default=[default]} > Preparing to download artifact info.picocli#picocli;4.2.0!picocli.jar > {noformat} > when {{-Dgroovy.grape.report.downloads=true}} is supplied. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (GROOVY-9533) not able to download data using groovy script
Siva Kandukuri created GROOVY-9533: -- Summary: not able to download data using groovy script Key: GROOVY-9533 URL: https://issues.apache.org/jira/browse/GROOVY-9533 Project: Groovy Issue Type: Question Components: Groovy Console Environment: test environment demo Reporter: Siva Kandukuri Attachments: testsapdata.txt hi i am trying connect to SAP cloud API and generate a access token and download the data through a groovy script. the script is is to connect to SAP sever and generate the access token but its not able to download the data. its throwing below error. same thing works in POSTMAN well and no issues there and able to download the data but here i grovvy script its throwing this. line 30 in script is where its throwing issue Server returned HTTP response code: 400 for URL: https://xuat.fgvms.com/api/vc/connector/Worker from Work Order Download I am using groovy playground for this to test. i attached the scruipt i am working on -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9528) CLIBuilder: "error: Missing required options" when unknown options are provided
[ https://issues.apache.org/jira/browse/GROOVY-9528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17096516#comment-17096516 ] Remko Popma commented on GROOVY-9528: - Thank you for adding the test. Also thank you for the heads up on the branch. Tomorrow I’ll double check the other commits I made recently. > CLIBuilder: "error: Missing required options" when unknown options are > provided > --- > > Key: GROOVY-9528 > URL: https://issues.apache.org/jira/browse/GROOVY-9528 > Project: Groovy > Issue Type: Bug > Components: command line processing >Affects Versions: 3.0.2 > Environment: Linux/Windows >Reporter: Dirk Heinrichs >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4, 2.5.12 > > > When passing an additional option to a script that doesn't know about this > option, I get an error message about "missing required options", listing all > required options that follow the unkown option. > The following example code reproduces the issue: > {code:java} > @Grab('info.picocli:picocli-groovy:4.2.0') > @GrabConfig(systemClassLoader=true) > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder(name: 'cliTest.groovy') > cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show > usage information') > cli.a(type: String, longOpt: 'optA', required: true, args: 1, 'Option a > (required)') > cli.b(type: String, longOpt: 'optB', required: true, args: 1, 'Option b > (required)') > // NOTE: No "-c|--optC" here > cli.d(type: String, longOpt: 'optD', required: true, args: 1, 'Option d > (required)') > cli.e(type: String, longOpt: 'optE', required: true, args: 1, 'Option e > (required)') > cli.f(type: String, longOpt: 'optF', required: false, args: 1, 'Option f > (optional)') > def opts = cli.parse(args) > opts || System.exit(1) > if(opts.h) { > cli.usage() > System.exit(0) > }{code} > When invoked with an additional option, '-c C' for example, it produces the > following, misleading output: > {code:java} > % ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy -a A -b B -c C -d D -e E > error: Missing required options [--optD=PARAM, --optE=PARAM] > Usage: cliTest.groovy [-h] -a=PARAM -b=PARAM -d=PARAM -e=PARAM [-f=PARAM] > -a, --optA=PARAM Option a (required) > -b, --optB=PARAM Option b (required) > -d, --optD=PARAM Option d (required) > -e, --optE=PARAM Option e (required) > -f, --optF=PARAM Option f (optional) > -h, --help Show usage information{code} > The list of missing options varies depending on where "-c C" is inserted. > There's no error when it's the last one. > I would expect it to either ignore the addtional option in all cases or emit > an error message about an unknown option. But in no case should it error out > because of missing required options when there are none missing. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Updated] (GROOVY-9528) CLIBuilder: "error: Missing required options" when unknown options are provided
[ https://issues.apache.org/jira/browse/GROOVY-9528?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King updated GROOVY-9528: -- Fix Version/s: 2.5.12 > CLIBuilder: "error: Missing required options" when unknown options are > provided > --- > > Key: GROOVY-9528 > URL: https://issues.apache.org/jira/browse/GROOVY-9528 > Project: Groovy > Issue Type: Bug > Components: command line processing >Affects Versions: 3.0.2 > Environment: Linux/Windows >Reporter: Dirk Heinrichs >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4, 2.5.12 > > > When passing an additional option to a script that doesn't know about this > option, I get an error message about "missing required options", listing all > required options that follow the unkown option. > The following example code reproduces the issue: > {code:java} > @Grab('info.picocli:picocli-groovy:4.2.0') > @GrabConfig(systemClassLoader=true) > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder(name: 'cliTest.groovy') > cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show > usage information') > cli.a(type: String, longOpt: 'optA', required: true, args: 1, 'Option a > (required)') > cli.b(type: String, longOpt: 'optB', required: true, args: 1, 'Option b > (required)') > // NOTE: No "-c|--optC" here > cli.d(type: String, longOpt: 'optD', required: true, args: 1, 'Option d > (required)') > cli.e(type: String, longOpt: 'optE', required: true, args: 1, 'Option e > (required)') > cli.f(type: String, longOpt: 'optF', required: false, args: 1, 'Option f > (optional)') > def opts = cli.parse(args) > opts || System.exit(1) > if(opts.h) { > cli.usage() > System.exit(0) > }{code} > When invoked with an additional option, '-c C' for example, it produces the > following, misleading output: > {code:java} > % ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy -a A -b B -c C -d D -e E > error: Missing required options [--optD=PARAM, --optE=PARAM] > Usage: cliTest.groovy [-h] -a=PARAM -b=PARAM -d=PARAM -e=PARAM [-f=PARAM] > -a, --optA=PARAM Option a (required) > -b, --optB=PARAM Option b (required) > -d, --optD=PARAM Option d (required) > -e, --optE=PARAM Option e (required) > -f, --optF=PARAM Option f (optional) > -h, --help Show usage information{code} > The list of missing options varies depending on where "-c C" is inserted. > There's no error when it's the last one. > I would expect it to either ignore the addtional option in all cases or emit > an error message about an unknown option. But in no case should it error out > because of missing required options when there are none missing. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9528) CLIBuilder: "error: Missing required options" when unknown options are provided
[ https://issues.apache.org/jira/browse/GROOVY-9528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17096448#comment-17096448 ] Paul King commented on GROOVY-9528: --- [~rpopma] I cherry-picked onto GROOVY_2_5_X and added a test. We don't maintain GROOVY_2_6_X any more. It was Groovy 3 backed-ported for JDK 7 but we decided to just go with Groovy 3 and JDK 8. > CLIBuilder: "error: Missing required options" when unknown options are > provided > --- > > Key: GROOVY-9528 > URL: https://issues.apache.org/jira/browse/GROOVY-9528 > Project: Groovy > Issue Type: Bug > Components: command line processing >Affects Versions: 3.0.2 > Environment: Linux/Windows >Reporter: Dirk Heinrichs >Assignee: Remko Popma >Priority: Major > Fix For: 3.0.4 > > > When passing an additional option to a script that doesn't know about this > option, I get an error message about "missing required options", listing all > required options that follow the unkown option. > The following example code reproduces the issue: > {code:java} > @Grab('info.picocli:picocli-groovy:4.2.0') > @GrabConfig(systemClassLoader=true) > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder(name: 'cliTest.groovy') > cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show > usage information') > cli.a(type: String, longOpt: 'optA', required: true, args: 1, 'Option a > (required)') > cli.b(type: String, longOpt: 'optB', required: true, args: 1, 'Option b > (required)') > // NOTE: No "-c|--optC" here > cli.d(type: String, longOpt: 'optD', required: true, args: 1, 'Option d > (required)') > cli.e(type: String, longOpt: 'optE', required: true, args: 1, 'Option e > (required)') > cli.f(type: String, longOpt: 'optF', required: false, args: 1, 'Option f > (optional)') > def opts = cli.parse(args) > opts || System.exit(1) > if(opts.h) { > cli.usage() > System.exit(0) > }{code} > When invoked with an additional option, '-c C' for example, it produces the > following, misleading output: > {code:java} > % ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy -a A -b B -c C -d D -e E > error: Missing required options [--optD=PARAM, --optE=PARAM] > Usage: cliTest.groovy [-h] -a=PARAM -b=PARAM -d=PARAM -e=PARAM [-f=PARAM] > -a, --optA=PARAM Option a (required) > -b, --optB=PARAM Option b (required) > -d, --optD=PARAM Option d (required) > -e, --optE=PARAM Option e (required) > -f, --optF=PARAM Option f (optional) > -h, --help Show usage information{code} > The list of missing options varies depending on where "-c C" is inserted. > There's no error when it's the last one. > I would expect it to either ignore the addtional option in all cases or emit > an error message about an unknown option. But in no case should it error out > because of missing required options when there are none missing. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Assigned] (GROOVY-9432) ClassNotFoundException when attempting to use Picocli via Grapes
[ https://issues.apache.org/jira/browse/GROOVY-9432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Remko Popma reassigned GROOVY-9432: --- Assignee: Remko Popma > ClassNotFoundException when attempting to use Picocli via Grapes > > > Key: GROOVY-9432 > URL: https://issues.apache.org/jira/browse/GROOVY-9432 > Project: Groovy > Issue Type: Bug > Components: Grape >Affects Versions: 3.0.0, 3.0.1 > Environment: Reproduced under both macOS (Groovy 3.0.1 installed > manually and via MacPorts) and Debian (Groovy installed via SDKMAN). >Reporter: Marc Simpson >Assignee: Remko Popma >Priority: Major > Attachments: image-2020-03-03-14-30-10-210.png > > > (Issue originally raised as: https://github.com/remkop/picocli/issues/970) > Consider the following minimal script: > {noformat} > @Grab('info.picocli:picocli:4.2.0') > import groovy.cli.picocli.CliBuilder > def cli = new CliBuilder() > {noformat} > Under Groovy 2.5.9, this runs without error; with 3.0.1, however, I see: > {noformat} > $ groovy cli.groovy > Caught: java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException > at cli.run(cli.groovy:4) > at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > Caused by: java.lang.ClassNotFoundException: > picocli.CommandLine$ParameterException > ... 4 more > {noformat} > The jar is definitely downloaded to {{~/.groovy/grapes}} and both versions of > Groovy output > {noformat} > Resolving dependency: info.picocli#picocli;4.2.0 {default=[default]} > Preparing to download artifact info.picocli#picocli;4.2.0!picocli.jar > {noformat} > when {{-Dgroovy.grape.report.downloads=true}} is supplied. -- This message was sent by Atlassian Jira (v8.3.4#803005)