Skip to content

Commit

Permalink
Documentation improvements
Browse files Browse the repository at this point in the history
* fix anchor links in various links to api docs
* change links to GraalVM docu to latest version
* bump gradle to latest version 7.6
  • Loading branch information
deining authored and remkop committed Nov 29, 2022
1 parent 2a4f9ff commit 1f26852
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ Substrate VM is the name for the runtime components (like the deoptimizer, garba
=== Native Image Limitations

To keep the implementation small and concise, and also to allow aggressive ahead-of-time optimizations, Native Image does not support all features of Java.
The full set of https://www.graalvm.org/reference-manual/native-image/Limitations/[limitations] is documented in the GraalVM reference manual.
The https://www.graalvm.org/latest/reference-manual/native-image/metadata/Compatibility/#features-that-may-operate-differently-in-a-native-image[features] that may operate differently are documented in the GraalVM reference manual.

Two limitations are of particular interest:

* https://www.graalvm.org/reference-manual/native-image/Limitations/#reflection[reflection]
* https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/Resources/[resources]
* https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Reflection/[reflection]
* https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Resources/[resources]

Basically, to create a self-contained binary, the native image compiler needs to know up-front all the classes of your application, their dependencies, and the resources they use. Reflection and resource bundles often require configuration. We will see an example of this later on.

Expand Down Expand Up @@ -198,7 +198,7 @@ Next, let’s take a look at turning it into a native executable.

=== Reflection Configuration

We mentioned earlier that the native image compiler has some limitations: reflection is supported but https://www.graalvm.org/22.2/reference-manual/native-image/overview/BuildConfiguration/[requires configuration].
We mentioned earlier that the native image compiler has some limitations: reflection is supported but https://www.graalvm.org/latest/reference-manual/native-image/overview/BuildConfiguration/[requires configuration].

This impacts picocli-based applications: at runtime, picocli uses reflection to discover any `@Command`-annotated subcommands, and the `@Option` and `@Parameters`-annotated command options and positional parameters.

Expand Down Expand Up @@ -239,7 +239,7 @@ This quickly becomes quite cumbersome for utilities with many options, but fortu
The `picocli-codegen` module includes an annotation processor that can build a model from the picocli annotations at compile time rather than at runtime.

The annotation processor generates Graal configuration files under `META-INF/native-image/picocli-generated/$project` during compilation, to be included in the application jar.
This includes configuration files for https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/Reflection/[reflection], https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/Resources/[resources] and https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/DynamicProxy/[dynamic proxies].
This includes configuration files for https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Reflection/[reflection], https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Resources/[resources] and https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/DynamicProxy/[dynamic proxies].
By embedding these configuration files, your jar is instantly Graal-enabled.
In most cases no further configuration is needed when generating a native image.

Expand Down
32 changes: 16 additions & 16 deletions docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ The `picocli-codegen` module includes an annotation processor that can build a m
Enabling this annotation processor in your project is optional, but strongly recommended. Use this if you’re interested in:

* **Compile time error checking**. The annotation processor shows errors for invalid annotations and attributes immediately when you compile, instead of during testing at runtime, resulting in shorter feedback cycles.
* **<<GraalVM Native Image,GraalVM native images>>**. The annotation processor generates and updates https://www.graalvm.org/22.2/reference-manual/native-image/overview/BuildConfiguration/[GraalVM configuration] files under
* **<<GraalVM Native Image,GraalVM native images>>**. The annotation processor generates and updates https://www.graalvm.org/latest/reference-manual/native-image/overview/BuildConfiguration/[GraalVM configuration] files under
`META-INF/native-image/picocli-generated/$project` during compilation, to be included in the application jar.
This includes configuration files for https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/Reflection/[reflection], https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/Resources/[resources] and https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/DynamicProxy/[dynamic proxies].
This includes configuration files for https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Reflection/[reflection], https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Resources/[resources] and https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/DynamicProxy/[dynamic proxies].
By embedding these configuration files, your jar is instantly Graal-enabled.
In most cases no further configuration is needed when generating a native image.

Expand Down Expand Up @@ -1857,7 +1857,7 @@ Enum value matching is case-sensitive by default, but as of picocli 3.4 this can
== Default Values
It is possible to define a default value for an option or positional parameter, that is assigned when the user did not specify this option or positional parameter on the command line.

Configuring a default value guarantees that the `@Option` or `@Parameters`-annotated field will get set, annotated method will get called, and, when using the programmatic API, that the https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Model.ArgSpec.html#setValue-T-[`ArgSpec.setValue`] method will get invoked, even when the option or positional parameter was not specified on the command line.
Configuring a default value guarantees that the `@Option` or `@Parameters`-annotated field will get set, annotated method will get called, and, when using the programmatic API, that the https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Model.ArgSpec.html#setValue(T)[`ArgSpec.setValue`] method will get invoked, even when the option or positional parameter was not specified on the command line.

[#defaultValue-annotation]
=== `defaultValue` Annotation
Expand Down Expand Up @@ -2053,11 +2053,11 @@ cmd.execute(*args)
==== PropertiesDefaultProvider Format
The `PropertiesDefaultProvider` expects the properties file to be in the standard java `.properties` https://en.wikipedia.org/wiki/.properties[format].

For options, the key is either the https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Option.html#descriptionKey--[descriptionKey],
or the option's https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Model.OptionSpec.html#longestName--[longest name], without the prefix. So, for an option `--verbose`, the key would be `verbose`, and for an option `/F`, the key would be `F`.
For options, the key is either the https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Option.html#descriptionKey()[descriptionKey],
or the option's https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Model.OptionSpec.html#longestName()[longest name], without the prefix. So, for an option `--verbose`, the key would be `verbose`, and for an option `/F`, the key would be `F`.

For positional parameters, the key is either the https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Parameters.html#descriptionKey--[descriptionKey],
or the positional parameter's https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Parameters.html#paramLabel--[param label].
For positional parameters, the key is either the https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Parameters.html#descriptionKey()[descriptionKey],
or the positional parameter's https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Parameters.html#paramLabel()[param label].

End users may not know what the `descriptionKey` of your options and positional parameters are, so be sure to document that with your application.

Expand Down Expand Up @@ -4114,7 +4114,7 @@ When the user specified invalid input, the parser throws a `ParameterException`.
In the `execute` method, such exceptions are caught and passed to the `IParameterExceptionHandler`.

The default parameter exception handler prints an error message describing the problem,
followed by either https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.UnmatchedArgumentException.html#printSuggestions-picocli.CommandLine.ParameterException-java.io.PrintWriter-[suggested alternatives]
followed by either https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.UnmatchedArgumentException.html#printSuggestions(picocli.CommandLine.ParameterException,java.io.PrintWriter)[suggested alternatives]
for mistyped options, or the full usage help message of the problematic command.
Finally, the handler returns an <<Exception Exit Codes,exit code>>.
This is sufficient for most applications.
Expand Down Expand Up @@ -5289,7 +5289,7 @@ This allows you to control:
* the negative form recognized by the parser while parsing the command line
* the documentation string showing both the positive and the negative form in the usage help message

By default, a set of https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.RegexTransformer.html#createDefault--[regular expressions] is used to control the above.
By default, a set of https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.RegexTransformer.html#createDefault()[regular expressions] is used to control the above.
Use `CommandLine::setNegatableOptionTransformer` to replace the https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.INegatableOptionTransformer[`INegatableOptionTransformer`] with a custom version.
See the JavaDoc for details.

Expand Down Expand Up @@ -8852,7 +8852,7 @@ The default link:#_executing_commands_with_subcommands[`IExecutionStrategy`] (`p
toplevelcmd subcmd-A subcmd-B subsub-B1 subsub-B2
----

is invoked, only the last two sub-subcommands `subsub-B1` and `subsub-B2` (who both have parent command `subcmd-B`) are executed by default. You can https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.html#setExecutionStrategy-picocli.CommandLine.IExecutionStrategy-[set] a different https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.IExecutionStrategy.html[execution strategy] if this does not meet your needs.
is invoked, only the last two sub-subcommands `subsub-B1` and `subsub-B2` (who both have parent command `subcmd-B`) are executed by default. You can https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.html#setExecutionStrategy(picocli.CommandLine.IExecutionStrategy)[set] a different https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.IExecutionStrategy.html[execution strategy] if this does not meet your needs.


=== Usage Help for Subcommands
Expand Down Expand Up @@ -9995,7 +9995,7 @@ The matching entry in the resource bundle could look like this:
xoption = This is the description for the -x option.
----

When the `descriptionKey` is omitted, the https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Option.html#descriptionKey--[fallback for options] is any option name without the leading dashes, for example:
When the `descriptionKey` is omitted, the https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Option.html#descriptionKey()[fallback for options] is any option name without the leading dashes, for example:

.Java
[source,java,role="primary"]
Expand All @@ -10015,7 +10015,7 @@ verbose = Show more detail during execution. \
May be specified multiple times for increasing verbosity.
----

For https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Parameters.html#descriptionKey--[positional parameters] the fallback key is the `paramLabel + [ index ]`, for example:
For https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Parameters.html#descriptionKey()[positional parameters] the fallback key is the `paramLabel + [ index ]`, for example:

.Java
[source,java,role="primary"]
Expand Down Expand Up @@ -12451,7 +12451,7 @@ assertEquals("expectedValue1", app.state1)
assertEquals("expectedValue2", app.state2)
----

This assumes that the application uses the `PrintWriter` provided by https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.html#getOut--[`CommandLine.getOut`] or https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.html#getErr--[`CommandLine.getErr`].
This assumes that the application uses the `PrintWriter` provided by https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.html#getOut()[`CommandLine.getOut`] or https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.html#getErr()[`CommandLine.getErr`].
Applications can get these writers via the <<#spec-annotation,`@Spec`>> annotation:

.Java
Expand Down Expand Up @@ -12927,8 +12927,8 @@ ahead-of-time compile Java code to a standalone executable, called a native imag
The resulting executable includes the application, the libraries, and the JDK and does not require a separate Java VM to be installed.
The generated native image has faster startup time and lower runtime memory overhead compared to a Java VM.

GraalVM native images have some limitations and require some extra https://www.graalvm.org/22.2/reference-manual/native-image/overview/BuildConfiguration/[configuration]
to be able to use features like https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/Reflection/[reflection], https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/Resources/[resources] (including resource bundles) and https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/DynamicProxy/[dynamic proxies].
GraalVM native images have some limitations and require some extra https://www.graalvm.org/latest/reference-manual/native-image/overview/BuildConfiguration/[configuration]
to be able to use features like https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Reflection/[reflection], https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Resources/[resources] (including resource bundles) and https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/DynamicProxy/[dynamic proxies].

==== How do I Create a Native Image for my Application?
The `picocli-codegen` module contains an annotation processor that generates the necessary configuration files
Expand All @@ -12937,7 +12937,7 @@ to be included in the application jar. The <<Annotation Processor>> section of t
file.

By embedding these configuration files, your jar is instantly Graal-enabled: the
https://www.graalvm.org/22.2/reference-manual/native-image/#install-native-image[`native-image` tool]
https://www.graalvm.org/latest/reference-manual/native-image/#install-native-image[`native-image` tool]
used to generate the native executable is able to get the configuration from the jar.
In most cases no further configuration is needed when generating a native image.

Expand Down
2 changes: 1 addition & 1 deletion docs/picocli-on-graalvm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The generated `reflect.json` files looks something like this:
TIP: If necessary, it is possible to exclude classes with system property `picocli.codegen.excludes`, which accepts a comma-separated list of regular expressions of the fully qualified class names that should not be included in the resulting JSON String.

=== Compiling a Native Image
This assumes you have GraalVM installed, with prerequisites. From https://www.graalvm.org/22.2/reference-manual/native-image/[the site]:
This assumes you have GraalVM installed, with prerequisites. From https://www.graalvm.org/latest/reference-manual/native-image/[the site]:

[quote]
____
Expand Down
4 changes: 2 additions & 2 deletions docs/picocli-programmatic-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ the parser will create a https://picocli.info/#_strongly_typed_everything[strong
that was matched on the command line. Picocli stores this value in the `ArgSpec` by using its `IGetter` or `ISetter`.

Most applications don't need to know the details of getter and setter bindings, and can just call
https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Model.ArgSpec.html#getValue--[getValue] or
https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Model.ArgSpec.html#setValue-T-[setValue].
https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Model.ArgSpec.html#getValue()[getValue] or
https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.Model.ArgSpec.html#setValue(T)[setValue].
The below may be of interest for applications or libraries that use picocli to design a domain-specific language, or implement some other dynamic behaviour.

Picocli internally uses bindings to allow `@Option` and `@Parameters`-annotated fields and setter methods on implementation classes, and annotated getter methods on interfaces.
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/picocli-2.0-groovy-scripts-on-steroids.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ image:AllYourBase.png[Alt="你们所有的基地都属于我们",width='35%']

* 否则,执行脚本主体。

此行为可以自定义,有关更多详情,请参见 http://picocli.info/apidocs-all/info.picocli.groovy/picocli/groovy/PicocliBaseScript.html#run--[Picocli基础脚本文档]。
此行为可以自定义,有关更多详情,请参见 http://picocli.info/apidocs-all/info.picocli.groovy/picocli/groovy/PicocliBaseScript.html#run()[Picocli基础脚本文档]。

除了修改脚本基类之外, `@PicocliScript` 注释还允许Groovy脚本直接使用 `@Command` 注释,而无需引入助手类。
Picocli解析器将在含有 `@Option` 和 `@Parameters` 注释字段的类中寻找此注释。
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 1f26852

Please sign in to comment.