Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
The background for this request is annotations in the picocli library. The annotations API of this library allows applications to specify a class or an array of classes to customize some behaviour. For example:
// current picocli (4.5.2) requires explicit class(es), does not support Closures @Option(names = "-x", completionCandidates = MyCandidates.class, converter = [StringConverter.class, MessageDigestConverter.class]) Map<String, MessageDigest> someOption;
There is work in progress in the picocli library to allow applications to specify closures for such classes in the annotations. For example, I would like applications to be able to do this:
// next version of picocli (4.6.0) aims to support Closures in these annotation attributes @picocli.CommandLine.Option(names = "-x", completionCandidates = {["A", "B", "C"]}, converter = [ {it}, { str -> java.security.MessageDigest.getInstance(str) } ]) Map<String, java.security.MessageDigest> someOption
With the current version of Groovy (3.0.6), this works for the single-value attributes like completionCandidates, but does not work for attributes that take an array of values, like converter.
Please add support for arrays in the Closure to Class conversion for annotations.
See also discussion on the groovy-dev mailing list.