Skip to content

Commit

Permalink
[#1308] DOC: improve text for default values; RELEASE-NOTES
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Jan 16, 2021
1 parent 034c9c4 commit ad7cdd2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Picocli follows [semantic versioning](http://semver.org/).
* [#1304] DOC: Manual, chapter '17.9 Inherited Command Attributes': added Kotlin version of code sample. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
* [#1305] DOC: Document use of `IParameterConsumer` as n-ary type converter. Thanks to [Martin](https://github.com/martlin2cz) for raising this.
* [#1307] DOC: Added CAUTION admonitions, Kotlin code sample. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
* [#1308] DOC: Add example for Option `converter`.
* [#1308] DOC: Add example for Option `converter`, improve text for default values. Thanks to [Abhijit Sarkar](https://github.com/asarkar) for raising this.

## <a name="4.6.2-deprecated"></a> Deprecations
No features were deprecated in this release.
Expand Down
2 changes: 2 additions & 0 deletions docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,8 @@ 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/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
The recommended way to give an option or positional parameter a default value is to use the `defaultValue` annotation attribute. This works correctly with argument groups, `@Option` and `@Parameters`-annotated methods, and allows annotation processors to detect and use default values.
Expand Down
3 changes: 3 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4405,6 +4405,9 @@ <h2 id="_default_values"><a class="anchor" href="#_default_values"></a>5. Defaul
<div class="paragraph">
<p>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.</p>
</div>
<div class="paragraph">
<p>Configuring a default value guarantees that the <code>@Option</code> or <code>@Parameters</code>-annotated field will get set, annotated method will get called, and, when using the programmatic API, that the <a href="https://picocli.info/apidocs/picocli/CommandLine.Model.ArgSpec.html#setValue-T-"><code>ArgSpec.setValue</code></a> method will get invoked, even when the option or positional parameter was not specified on the command line.</p>
</div>
<div class="sect2">
<h3 id="defaultValue-annotation"><a class="anchor" href="#defaultValue-annotation"></a>5.1. <code>defaultValue</code> Annotation</h3>
<div class="paragraph">
Expand Down

0 comments on commit ad7cdd2

Please sign in to comment.