chore(deps): update picocli.version to v4.6.2 #648
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
4.5.2
->4.6.2
4.5.2
->4.6.2
Release Notes
remkop/picocli
v4.6.2
Compare Source
The picocli community is pleased to announce picocli 4.6.2.
This release includes bugfixes and enhancements. Many improvements in the documentation.
Thanks to the many people in the picocli community for raising issues and contributing pull requests to fix issues!
From this release, picocli uses system properties
sun.stdout.encoding
andsun.stderr.encoding
when creating thePrintWriters
returned byCommandLine::getOut
andCommandLine::getErr
.When these system properties do not exist, picocli falls back to the default charset (determined by
file.encoding
).This addresses an issue on Windows, where the default charset is not the same as the encoding for its console (often the older
cp437
codepage on English-language versions of Windows).Note that these system properties seem to have been introduced in Java 8 (although I cannot find it in the JDK 8 release notes) and may not exist on earlier JVMs or on JVMs other than the Oracle and OpenJDK implementations.
This is the seventy-seventh public release.
Picocli follows semantic versioning.
Table of Contents
New and Noteworthy
Fixed issues
@Option
help
attribute; it is useful for custom help options. Thanks to kaushalkumar for raising this.WARNING: tag not found in include file
messages when generating man pages. Thanks to Philip Crotwell for the pull request.completionCandidates
when displaying usage help if${COMPLETION-CANDIDATES}
is not specified in description. Thanks to Wenhao ZHANG, sustc11810424 and Yining Tang for the pull request.IllegalArgumentException: argument type mismatch
error in method subcommands with inherited mixed-in standard help options. Thanks to Andreas Deininger for raising this.CommandLine
with ArgGroup. Thanks to Yashodhan Ghadge for raising this.DuplicateOptionAnnotationsException
thrown onmixinStandardHelpOptions
for subcommands when parent hasscope = INHERIT
bypicocli-codegen
annotation processor. Thanks to Philippe Charles for raising this.DuplicateOptionAnnotationsException
when parent has inherited mixed-in help options and the built-inHelpCommand
subcommand. Thanks to Andreas Deininger for raising this.IllegalArgumentException
when parent has no standard help options andscope = INHERIT
, while subcommand does have mixed-in standard help options. Thanks to Andreas Deininger for raising this.CommandSpec.remove(arg)
should also remove the arg from theargs
collection in the CommandSpec. Thanks to kaushalkumar for the pull request.sun.stdout.encoding
andsun.stderr.encoding
when creating thePrintWriters
returned byCommandLine::getOut
andCommandLine::getErr
. Thanks to Philippe Charles for the investigation and the pull request..gitattributes
should include HTML files to convert CRLF to LF. Thanks to wenhoujx for pointing this out.execute
method inRunAll
,RunFirst
andRunLast
should not be deprecated. Thanks to Gamal DeWeever for raising this.IParameterPreprocessor
fromIParameterConsumer
javadoc. Thanks to Andreas Deininger for the pull request.IParameterConsumer
as n-ary type converter. Thanks to Martin for raising this.converter
, improve text for default values. Thanks to Abhijit Sarkar for raising this.setLongOptionsMaxWidth
tosetUsageHelpLongOptionsMaxWidth
in user manual section 'Long Option Column Width'. Thanks to kunlk for raising this.picocli-shell-jline2/README.md
. Thanks to Ahmed Ashour for the pull request.MANIFEST.MF
. Thanks to Fiouz for the pull request.pom.xml
. Thanks to Fiouz for the pull request.Deprecations
No features were deprecated in this release.
The
@Option
help
attribute is no longer deprecated from this release; it is useful for custom help options.Potential breaking changes
This release has no breaking changes.
v4.6.1
Compare Source
The picocli community is pleased to announce picocli 4.6.1.
This release fixes a problem with dependency scope in the following sub-modules:
The problem was that these modules contained dependencies that were declared to have
implementation
scope instead ofapi
scope.However, these were transitive dependencies, and necessary to compile any project that uses the above picocli modules.
In this release, transitive dependencies are declared with
api
scope in the above modules.Special thanks to Sualeh Fatehi, Dejan Stojadinović and Semyon Levin for the quick community feedback, pull request and reviews!
This is the seventy-sixth public release.
Picocli follows semantic versioning.
Table of Contents
New and Noteworthy
Fixed issues
picocli-shell-jline3
. Thanks to Sualeh Fatehi for raising this.picocli-shell-jline3
. Thanks to Dejan Stojadinović for the pull request, and Semyon Levin for the review.picocli-spring-boot-starter
. Thanks to Semyon Levin for raising this.Deprecations
No features were deprecated in this release.
Potential breaking changes
This release has no breaking changes.
v4.6.0
Compare Source
The picocli community is pleased to announce picocli 4.6.0.
This release contains new features, bug fixes and other enhancements.
Community Contributions
This release contains many, many community contributions, for which I am extremely grateful. Let's give them some credit!
IModelTransformer
API for user-defined model transformations after initialization and before parsing.picocli-shell-jline3
module that adds a built-inclear
command and improves thehelp
command.echo
andprompt
for interactive options and positional parameters.Annotation::getClass
and assignment inif
condition.@ParentObject
should be@ParentCommand
.@Command
attributes withscope=INHERIT
.CommandSpec::removeSubcommand
method.Optional<T>
type for options and positional parameters.-Dkey
as well as-Dkey=value
).@Spec
-annotated members inArgGroup
classes.MissingParameterException
should not be thrown when subcommand has required options and help option is specified on parent command.ReflectionConfigGenerator
should not generate method section in subclass config for private superclass methods inreflect-config.json
.CommandLine::getFactory
accessor method.What is in this release
Improved Groovy support: this release introduces a new
@PicocliScript2
annotation that adds support for exit codes and@Command
-annotated methods to define subcommands. Also, from this release, Groovy programs can use closures in the picocli annotations instead of specifying a class.From this release, Map options accept key-only parameters, so end users can specify
-Dkey
as well as-Dkey=value
.There is a new
mapFallbackValue
attribute that enables this, which can be used to control the value that is put into the map when only a key was specified on the command line.Also, this release adds support for
java.util.Optional<T>
: single-value types can be wrapped in anOptional
container object when running on Java 8 or higher.If the option or positional parameter was not specified on the command line, picocli assigns the value
Optional.empty()
instead ofnull
.This release also adds support for commands with
scope = ScopeType.INHERIT
. Commands with this scope have their attributes copied to all subcommands (and sub-subcommands).New parser plugin:
IParameterPreprocessor
and new configuration plugin:IModelTransformer
.From this release,
@Spec
-annotated elements can be used inArgGroup
classes, which can be convenient for validation.Interactive options and positional parameters can now set
echo = true
(for non-security sensitive data) so that user input is echoed to the console, and control theprompt
text that is shown before asking the user for input.Help API: this release adds public methods
Help.Layout::colorScheme
,Help.Layout::textTable
,Help.Layout::optionRenderer
,Help.Layout::parameterRenderer
, andHelp::calcLongOptionColumnWidth
, making it easier to customize the table format used to lay out options and positional parameters in the usage help message.CommandSpec API: added method
CommandSpec::removeSubcommand
.This is the seventy-fifth public release.
Picocli follows semantic versioning.
Table of Contents
@PicocliScript2
annotationjava.util.Optional<T>
New and Noteworthy
New
@PicocliScript2
annotationThe older
@picocli.groovy.PicocliScript
annotation is deprecated from picocli 4.6.New scripts should use the
@picocli.groovy.PicocliScript2
annotation (and associatedpicocli.groovy.PicocliBaseScript2
base class) instead.The table below lists the differences between the
PicocliBaseScript2
andPicocliBaseScript
script base classes.PicocliBaseScript2
PicocliBaseScript
@Command
-annotated methods in the script.@Command
-annotated methods.help
subcommands (both the built-in one and custom ones).help
subcommands.afterExecution(CommandLine, int, Exception)
to callSystem.exit
.CommandLine::execute
. Scripts can overridebeforeParseArgs(CommandLine)
to install a customIExecutionStrategy
.PicocliBaseScript::run
and is not easy to customize. Any subcommand and the main script are both executed.beforeParseArgs(CommandLine)
to install a customIParameterExceptionHandler
.PicocliBaseScript::handleParameterException
.beforeParseArgs(CommandLine)
to install a customIExecutionExceptionHandler
.PicocliBaseScript::handleExecutionException
.Callable<Object>
, script body is transformed to thecall
method.runScriptBody
method.Groovy Closures in Annotations
From picocli 4.6, Groovy programs can use closures in the picocli annotations instead of specifying a class.
This can be especially useful in Groovy scripts, where one cannot define a static inner class.
Example:
When a class is specified, picocli creates an instance of the class. By contrast, when a closure is specified, picocli calls the closure to get an instance.
(To be precise, both of these are delegated to the configured factory, and the default factory implementation supports closures from picocli 4.6.)
As you can see in the above example, each closure in the annotation should contain another closure that has the required type (
IVersionProvider
,IDefaultValueProvider
, etc.)versionProvider
: note the empty parameter list before the->
arrow. This is needed to help the Groovy compiler. The closure must be cast toIVersionProvider
.defaultProvider
: return a default value for the specifiedArgSpec
parameter. The closure must be cast toIDefaultValueProvider
.completionCandidates
: return a list of Strings. No parameter list or casting is required.parameterConsumer
: given aStack
,ArgSpec
andCommandSpec
, process the remaining arguments. The closure must be cast toIParameterConsumer
.converter
takes an array of closures. Groovy 3.0.7 or greater is required: older versions of Groovy ignore closures in class array annotations. Each closure must have a parameter and be cast toITypeConverter
.Key-only map parameters
By default, picocli expects Map options and positional parameters to look like
key=value
, that is, the option parameter or positional parameter is expected to have a key part and a value part, separated by a=
character. If this is not the case, picocli shows a user-facing error message:Value for ... should be in KEY=VALUE format but was ...
.From picocli 4.6, applications can specify a
mapFallbackValue
to allow end users to specify only the key part. The specifiedmapFallbackValue
is put into the map when end users to specify only a key. The value type can be wrapped in ajava.util.Optional
. For example:This allows input like the following:
The above input would give the following results:
Note that the option description may contain the
${MAP-FALLBACK-VALUE}
variable which will be replaced with the actual map fallback value when the usage help is shown.System Properties
A common requirement for command line applications is to support the
-Dkey=value
syntax to allow end users to set system properties.The example below uses the
Map
type to define an@Option
-annotated method that delegates all key-value pairs toSystem::setProperty
.Note the use of
mapFallbackValue = ""
to allow key-only option parameters.java.util.Optional<T>
From version 4.6, picocli supports single-value types wrapped in a
java.util.Optional
container when running on Java 8 or higher.If the option or positional parameter was not specified on the command line, picocli assigns the value
Optional.empty()
instead ofnull
.For example:
WARNING: Picocli has only limited support for
java.util.Optional
types:only single-value types, and the values in a
Map
(but not the keys!) can be wrapped in anOptional
container.java.util.Optional
cannot be combined with arrays or otherCollection
classes.Inherited Command Attributes
Picocli 4.6 adds support for inheriting
@Command
attributes with thescope = ScopeType.INHERIT
annotation.Commands with this scope have their
@Command
attributes copied to all subcommands (and sub-subcommands, to any level of depth).When a subcommand specifies an explicit value in its
@Command
annotation, this value is used instead of the inherited value.For example:
The
app
command in the above example hasscope = ScopeType.INHERIT
, so its@Command
properties are inherited by thesub
subcommand.The
sub
subcommand defines its ownheader
anddescription
, so these are not inherited from the parent command.The help message for the subcommand looks like this:
Note that the subcommand has inherited the mixed-in standard help options (
--help
and--version
), the@file
usage help, and the footer and footer heading.It also inherited the version string, shown when the user invokes
app sub --version
.When a command has
scope = INHERIT
, the following attributes are copied to its subcommands:mixinStandardHelpOptions
helpCommand
Attributes that are not copied include:
mixinStandardHelpOptions
)mixinStandardHelpOptions
Preprocessor Parser Plugin
Introduced in picocli 4.6, the
IParameterPreprocessor
is also a parser plugin, similar toIParameterConsumer
, but more flexible.Options, positional parameters and commands can be assigned a
IParameterPreprocessor
that implements custom logic to preprocess the parameters for this option, position or command.When an option, positional parameter or command with a custom
IParameterPreprocessor
is matched on the command line, picocli's internal parser is temporarily suspended, and this custom logic is invoked.This custom logic may completely replace picocli's internal parsing for this option, positional parameter or command, or augment it by doing some preprocessing before picocli's internal parsing is resumed for this option, positional parameter or command.
The "preprocessing" actions can include modifying the stack of command line parameters, or modifying the model.
Example use case
This may be useful when disambiguating input for commands that have both a positional parameter and an option with an optional parameter.
For example, suppose we have a command with the following synopsis:
One of the limitations of options with an optional parameter is that they are difficult to combine with positional parameters.
With a custom parser plugin, we can customize the parser, such that
VALUE
in--option=VALUE
is interpreted as the option parameter, and in--option VALUE
(without the=
separator), VALUE is interpreted as the positional parameter.The code below demonstrates:
With this preprocessor, the following user input gives the following command state:
Configuration
📅 Schedule: At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR has been generated by WhiteSource Renovate. View repository job log here.