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 04:00:28 UTC

[groovy] branch GROOVY_2_6_X updated (ebbed0c -> 3c4f98c)

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

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


    from ebbed0c  fix(docs): cleanup links to spring framework docs * Remove ‘using-spring-factories-with-groovy’ link since there’s not an obvious intended reference * Use https urls * Point to current spring docs
     new cecfbcf  GROOVY-9531: improve CliBuilder documentation to clarify what functionality is available in which version
     new 3c4f98c  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] 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_2_6_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 3c4f98c983db3172412fdce9096eb044c222af08
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 c937250..0278493 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*


[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_2_6_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit cecfbcfd6994f709638dc1d28c8167c80d3c73db
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 b3ec6b6..c937250 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`