[jira] [Commented] (GROOVY-8577) Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli
[ https://issues.apache.org/jira/browse/GROOVY-8577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16785436#comment-16785436 ] Remko Popma commented on GROOVY-8577: - Great, thanks for the configuration! > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli > - > > Key: GROOVY-8577 > URL: https://issues.apache.org/jira/browse/GROOVY-8577 > Project: Groovy > Issue Type: Improvement > Components: command line processing >Reporter: Remko Popma >Assignee: Paul King >Priority: Major > Fix For: 2.5.0-rc-3 > > > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli as part of > GROOVY-8556. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8577) Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli
[ https://issues.apache.org/jira/browse/GROOVY-8577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16785412#comment-16785412 ] Piotr Zygielo commented on GROOVY-8577: --- [~rem...@yahoo.com] - thank you for confirmation and link to GROOVY-9012 (as it means no new issue has to be created to cover that case). Also - verified: commits [for 2_5_X|https://gitbox.apache.org/repos/asf?p=groovy.git;a=commit;h=e82bc44ff6e19eb405b486e503a35ca1e03ef60c] and [for master|https://gitbox.apache.org/repos/asf?p=groovy.git;a=commit;h=5deb67296dff179871ba2af9f87ef39e35645461|5deb67296d] deliver fix and in both trees {{resolve}} works as expected - thanks! Waiting for official 2.5.7 release then. > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli > - > > Key: GROOVY-8577 > URL: https://issues.apache.org/jira/browse/GROOVY-8577 > Project: Groovy > Issue Type: Improvement > Components: command line processing >Reporter: Remko Popma >Assignee: Paul King >Priority: Major > Fix For: 2.5.0-rc-3 > > > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli as part of > GROOVY-8556. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8577) Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli
[ https://issues.apache.org/jira/browse/GROOVY-8577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16784912#comment-16784912 ] Remko Popma commented on GROOVY-8577: - [~pzygielo], yes, this migration caused the issue you are referring to. Please see GROOVY-9012 for details. The issue has been fixed in master and the GROOVY_25_X branch and will be included in the next 2.5.7 release. Can you please verify that the fix resolves your issue correctly? > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli > - > > Key: GROOVY-8577 > URL: https://issues.apache.org/jira/browse/GROOVY-8577 > Project: Groovy > Issue Type: Improvement > Components: command line processing >Reporter: Remko Popma >Assignee: Paul King >Priority: Major > Fix For: 2.5.0-rc-3 > > > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli as part of > GROOVY-8556. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8577) Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli
[ https://issues.apache.org/jira/browse/GROOVY-8577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16784659#comment-16784659 ] Piotr Zygielo commented on GROOVY-8577: --- [~paulk] - I understand this issue is closed, but could I ask for comment on my [report above|https://issues.apache.org/jira/browse/GROOVY-8577?focusedCommentId=16768080&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16768080] from Feb 14th, please? > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli > - > > Key: GROOVY-8577 > URL: https://issues.apache.org/jira/browse/GROOVY-8577 > Project: Groovy > Issue Type: Improvement > Components: command line processing >Reporter: Remko Popma >Assignee: Paul King >Priority: Major > Fix For: 2.5.0-rc-3 > > > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli as part of > GROOVY-8556. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8577) Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli
[ https://issues.apache.org/jira/browse/GROOVY-8577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16768080#comment-16768080 ] Piotr Zygielo commented on GROOVY-8577: --- Hello Team I experience following issue with {{grape resolve}} command: {code} java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:114) at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:136) Caused by: groovyjarjarpicocli.CommandLine$ExecutionException: Error while running command (org.codehaus.groovy.tools.GrapeMain$Resolve@7f485fda): groovy.lang.MissingPropertyException: No such property: arg for class: org.codehaus.groovy.tools.GrapeMain at groovyjarjarpicocli.CommandLine.execute(CommandLine.java:865) at groovyjarjarpicocli.CommandLine.access$700(CommandLine.java:104) at groovyjarjarpicocli.CommandLine$RunLast.handle(CommandLine.java:1034) at groovyjarjarpicocli.CommandLine$RunLast.handle(CommandLine.java:1002) at groovyjarjarpicocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:910) at groovyjarjarpicocli.CommandLine.parseWithHandlers(CommandLine.java:1193) at groovyjarjarpicocli.CommandLine.parseWithHandler(CommandLine.java:1132) at groovyjarjarpicocli.CommandLine$parseWithHandler$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136) at org.codehaus.groovy.tools.GrapeMain.main(GrapeMain.groovy:72) ... 6 more Caused by: groovy.lang.MissingPropertyException: No such property: arg for class: org.codehaus.groovy.tools.GrapeMain at groovy.lang.MetaClassImpl.invokeStaticMissingProperty(MetaClassImpl.java:1021) at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1872) at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1848) at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3803) at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:193) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:470) at org.codehaus.groovy.tools.GrapeMain$Resolve.propertyMissing(GrapeMain.groovy) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:104) at groovy.lang.MetaClassImpl.invokeMissingProperty(MetaClassImpl.java:889) at groovy.lang.MetaClassImpl$12.getProperty(MetaClassImpl.java:2022) at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:85) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:310) at org.codehaus.groovy.tools.GrapeMain$Resolve.run(GrapeMain.groovy:235) at groovyjarjarpicocli.CommandLine.execute(CommandLine.java:857) ... 17 more {code} As shown at [https://travis-ci.org/pzrep/grape-picocli/builds/493167042] it worked with 2.4.16, stopped at 2.5.1, and between GROOVY-8577 was delivered I think. > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli > - > > Key: GROOVY-8577 > URL: https://issues.apache.org/jira/browse/GROOVY-8577 > Project: Groovy > Issue Type: Improvement > Components: command line processing >Reporter: Remko Popma >Assignee: Paul King >Priority: Major > Fix For: 2.5.0-rc-3 > > > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli as part of > GROOVY-8556. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8577) Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli
[ https://issues.apache.org/jira/browse/GROOVY-8577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16480032#comment-16480032 ] ASF GitHub Bot commented on GROOVY-8577: Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/704 > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli > - > > Key: GROOVY-8577 > URL: https://issues.apache.org/jira/browse/GROOVY-8577 > Project: Groovy > Issue Type: Task >Reporter: Remko Popma >Priority: Major > > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli as part of > GROOVY-8556. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8577) Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli
[ https://issues.apache.org/jira/browse/GROOVY-8577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16475145#comment-16475145 ] ASF GitHub Bot commented on GROOVY-8577: Github user remkop commented on a diff in the pull request: https://github.com/apache/groovy/pull/704#discussion_r188142573 --- Diff: src/main/groovy/org/codehaus/groovy/tools/GrapeMain.groovy --- @@ -19,290 +19,323 @@ package org.codehaus.groovy.tools import groovy.grape.Grape -import groovy.transform.Field -import org.apache.commons.cli.CommandLine -import org.apache.commons.cli.DefaultParser -import org.apache.commons.cli.HelpFormatter -import org.apache.commons.cli.Option -import org.apache.commons.cli.OptionGroup -import org.apache.commons.cli.Options import org.apache.ivy.util.DefaultMessageLogger import org.apache.ivy.util.Message - -//commands - -@Field install = {arg, cmd -> -if (arg.size() > 5 || arg.size() < 3) { -println 'install requires two to four arguments: [ []]' -return -} -def ver = '*' -if (arg.size() >= 4) { -ver = arg[3] -} -def classifier = null -if (arg.size() >= 5) { -classifier = arg[4] +import picocli.CommandLine +import picocli.CommandLine.Command +import picocli.CommandLine.Option +import picocli.CommandLine.Parameters +import picocli.CommandLine.ParentCommand +import picocli.CommandLine.RunLast +import picocli.CommandLine.Unmatched + +@Command(name = "grape", description = "Allows for the inspection and management of the local grape cache.", +subcommands = [ +Install.class, +Uninstall.class, +ListCommand.class, +Resolve.class, +picocli.CommandLine.HelpCommand.class]) +class GrapeMain implements Runnable { +@Option(names = ["-D", "--define"], description = "define a system property", paramLabel = "") +private Map properties = new LinkedHashMap() + +@Option(names = ["-r", "--resolver"], description = "define a grab resolver (for install)", paramLabel = "") +private List resolvers = new ArrayList() + +@Option(names = ["-q", "--quiet"], description = "Log level 0 - only errors") +private boolean quiet + +@Option(names = ["-w", "--warn"], description = "Log level 1 - errors and warnings") +private boolean warn + +@Option(names = ["-i", "--info"], description = "Log level 2 - info") +private boolean info + +@Option(names = ["-V", "--verbose"], description = "Log level 3 - verbose") +private boolean verbose + +@Option(names = ["-d", "--debug"], description = "Log level 4 - debug") +private boolean debug + +@Unmatched List unmatched = new ArrayList() + +private CommandLine parser + +public static void main(String[] args) { +GrapeMain grape = new GrapeMain() +def parser = new CommandLine(grape) +parser.addMixin("helpOptions", new HelpOptionsMixin()) +parser.subcommands.findAll { k, v -> k != 'help' }.each { k, v -> v.addMixin("helpOptions", new HelpOptionsMixin()) } + +grape.parser = parser +parser.parseWithHandler(new RunLast(), args) } -// set the instance so we can re-set the logger -Grape.getInstance() -setupLogging() +void run() { +if (unmatched) { +System.err.println "grape: '${unmatched[0]}' is not a grape command. See 'grape --help'" +} else { +parser.usage(System.out) // if no subcommand was specified +} +} -cmd.getOptionValues('r')?.each { String url -> -Grape.addResolver(name:url, root:url) +private void init() { +properties.each { k, v -> +System.setProperty(k, v) +} } -try { -Grape.grab(autoDownload: true, group: arg[1], module: arg[2], version: ver, classifier: classifier, noExceptions: true) -} catch (Exception e) { -println "An error occured : $ex" +private void setupLogging(int defaultLevel = 2) { // = Message.MSG_INFO -> some parsing error :( +if (quiet) { +Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_ERR)) +} else if (warn) { +Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_WARN)) +} else if (info) { +Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_INFO)) +} else if (verbose) { +Message.setDefaultLogger(new D
[jira] [Commented] (GROOVY-8577) Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli
[ https://issues.apache.org/jira/browse/GROOVY-8577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16472510#comment-16472510 ] ASF GitHub Bot commented on GROOVY-8577: GitHub user remkop opened a pull request: https://github.com/apache/groovy/pull/704 GROOVY-8577 Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli GROOVY-8577 Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli You can merge this pull request into a Git repository by running: $ git pull https://github.com/remkop/groovy GROOVY-8577-GrapeMain(attempt2) Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/704.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #704 commit 92d40dbb0305a901fcbacf6a313f1e5776889a70 Author: Remko Popma Date: 2018-05-10T16:27:36Z GROOVY-8577 Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli > - > > Key: GROOVY-8577 > URL: https://issues.apache.org/jira/browse/GROOVY-8577 > Project: Groovy > Issue Type: Task >Reporter: Remko Popma >Priority: Major > > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli as part of > GROOVY-8556. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8577) Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli
[ https://issues.apache.org/jira/browse/GROOVY-8577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16470813#comment-16470813 ] Remko Popma commented on GROOVY-8577: - The current {{GrapeMain.groovy}} implementation has the {{-r, --resolve=}} option as a global option on the top-level {{grape}} command, while it is only used by the {{grape install}} subcommand. Would it make sense to move this option so that it is no longer a global option but only an option of the {{grape install}} subcommand? > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli > - > > Key: GROOVY-8577 > URL: https://issues.apache.org/jira/browse/GROOVY-8577 > Project: Groovy > Issue Type: Task >Reporter: Remko Popma >Priority: Major > > Migrate org.codehaus.groovy.tools.GrapeMain.groovy to picocli as part of > GROOVY-8556. -- This message was sent by Atlassian JIRA (v7.6.3#76005)