You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by rp...@apache.org on 2020/04/29 03:58:20 UTC

[groovy] branch GROOVY_3_0_X updated (dfcdfaa -> 487d9c4)

This is an automated email from the ASF dual-hosted git repository.

rpopma pushed a change to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from dfcdfaa  GROOVY-9526: Failed to reload classes with generic parameters
     new 5fa2d88  GROOVY-9531: improve CliBuilder documentation to clarify what functionality is available in which version
     new 487d9c4  GROOVY-9528: improve the "parser" subsection of the "Picocli" section of "Advanced CLI Usage"  in domain-specific languages page

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/spec/doc/core-domain-specific-languages.adoc | 27 ++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)


[groovy] 01/02: GROOVY-9531: improve CliBuilder documentation to clarify what functionality is available in which version

Posted by rp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rpopma pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 5fa2d8804ecffbd26ea249e0900d4a7d7ffcbc4a
Author: Remko Popma <re...@yahoo.com>
AuthorDate: Wed Apr 29 12:09:25 2020 +0900

    GROOVY-9531: improve CliBuilder documentation to clarify what functionality is available in which version
    
    (cherry picked from commit 152930dfe85221a536f2efc62dd0e7e0d5e65807)
---
 src/spec/doc/core-domain-specific-languages.adoc | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/spec/doc/core-domain-specific-languages.adoc b/src/spec/doc/core-domain-specific-languages.adoc
index f88b013..bf2371a 100644
--- a/src/spec/doc/core-domain-specific-languages.adoc
+++ b/src/spec/doc/core-domain-specific-languages.adoc
@@ -1114,10 +1114,9 @@ def options = cli.parse(args)                              <5>
 if (options.h) cli.usage()                                 <6>
 else println "Hello ${options.a ? options.a : 'World'}"    <7>
 ---------------------------
-<1> Earlier versions of Groovy had a CliBuilder in the groovy.util package and no import was necessary.
-While still supported, this approach is now deprecated and you should instead choose the groovy.cli.picocli
-or groovy.cli.commons version. The groovy.util version points to the commons-cli version for backwards compatibility
-but will be removed in a future version of Groovy.
+<1> Earlier versions of Groovy had a CliBuilder in the `groovy.util` package and no import was necessary.
+In Groovy 2.5, this approach became deprecated: applications should instead choose the `groovy.cli.picocli` or `groovy.cli.commons` version.
+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.
 <2> define a new `CliBuilder` instance specifying an optional usage string
 <3> specify a `-a` option taking a single argument with an optional long variant `--audience`
 <4> specify a `-h` option taking no arguments with an optional long variant `--help`


[groovy] 02/02: GROOVY-9528: improve the "parser" subsection of the "Picocli" section of "Advanced CLI Usage" in domain-specific languages page

Posted by rp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rpopma pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 487d9c4df625dee611ddfd3ec056840c6109d304
Author: Remko Popma <re...@yahoo.com>
AuthorDate: Wed Apr 29 12:54:30 2020 +0900

    GROOVY-9528: improve the "parser" subsection of the "Picocli" section of "Advanced CLI Usage"  in domain-specific languages page
    
    (cherry picked from commit cbf130f31bff51b1cd1d492a6cdae04bec280ea3)
---
 src/spec/doc/core-domain-specific-languages.adoc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/spec/doc/core-domain-specific-languages.adoc b/src/spec/doc/core-domain-specific-languages.adoc
index bf2371a..f7bf4d5 100644
--- a/src/spec/doc/core-domain-specific-languages.adoc
+++ b/src/spec/doc/core-domain-specific-languages.adoc
@@ -1602,6 +1602,26 @@ image::assets/img/usageMessageSpec.png[]
 *New property: parser*
 
 The `parser` property gives access to the picocli `ParserSpec` object that can be used to customize the parser behavior.
+
+This can be useful when the `CliBuilder` options to control the parser are not fine-grained enough.
+For example, for backward compatibility with the Commons CLI implementation of `CliBuilder`, by default `CliBuilder` stops looking for options when an unknown option is encountered, and subsequent command line arguments are treated as positional parameters.
+`CliBuilder` provides a `stopAtNonOption` property, and by setting this to `false` you can make the parser more strict, so an unknown option results in `error: Unknown option: '-x'`.
+
+But what if you want to treat unknown options as positional parameters, and still process subsequent command line arguments as options?
+
+This can be accomplished with the `parser` property.
+For example:
+
+[source,groovy]
+----
+def cli = new CliBuilder()
+cli.parser.stopAtPositional(false)
+cli.parser.unmatchedOptionsArePositionalParams(true)
+// ...
+def opts = cli.parse(args)
+// ...
+----
+
 See the http://picocli.info/apidocs/picocli/CommandLine.Model.ParserSpec.html[documentation] for details.
 
 *Map options*