From e6d072bd150c526c58006438a72a53e3ff1e7b9a Mon Sep 17 00:00:00 2001 From: Remko Popma Date: Thu, 19 Aug 2021 16:18:16 +0900 Subject: [PATCH] [#1415] Bugfix/DOC: fix NullPointerException in README Example Closes #1415. --- RELEASE-NOTES.md | 1 + picocli-shell-jline3/README.md | 5 +++++ .../src/test/java/picocli/shell/jline3/example/Example.java | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 19865ed18..2feda2cef 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -33,6 +33,7 @@ Picocli follows [semantic versioning](http://semver.org/). * [#1331] Bugfix: Avoid `IllegalArgumentException` when parent has no standard help options and `scope = INHERIT`, while subcommand does have mixed-in standard help options. Thanks to [Andreas Deininger](https://github.com/deining) for raising this. * [#1381][#1382] Bugfix: Default value of option in repeated subcommand was not applied correctly. Thanks to [sfeuerhahn](https://github.com/sfeuerhahn) for the pull request. * [#1320][#1321] Bugfix/Enhancement: Use system properties `sun.stdout.encoding` and `sun.stderr.encoding` when creating the `PrintWriters` returned by `CommandLine::getOut` and `CommandLine::getErr`. Thanks to [Philippe Charles](https://github.com/charphi) for the investigation and the pull request. +* [#1415] Bugfix/DOC: fix NullPointerException in README Example. Thanks to [shannonbay](https://github.com/shannonbay) for raising this. * [#1326][#1339] DOC: Added documentation and examples for controlling the locale. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request. * [#1296] DOC: add Kotlin code samples to user manual; other user manual improvements. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request. * [#1299] DOC: Link to `IParameterPreprocessor` from `IParameterConsumer` javadoc. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request. diff --git a/picocli-shell-jline3/README.md b/picocli-shell-jline3/README.md index 363b7f03a..236a066cb 100644 --- a/picocli-shell-jline3/README.md +++ b/picocli-shell-jline3/README.md @@ -143,6 +143,10 @@ public class Example { CliCommands() {} + public void setReader(LineReader reader){ + out = reader.getTerminal().writer(); + } + public void run() { out.println(new CommandLine(this).getUsageMessage()); } @@ -250,6 +254,7 @@ public class Example { .variable(LineReader.LIST_MAX, 50) // max tab completion candidates .build(); builtins.setLineReader(reader); + commands.setReader(reader); factory.setTerminal(terminal); TailTipWidgets widgets = new TailTipWidgets(reader, systemRegistry::commandDescription, 5, TailTipWidgets.TipType.COMPLETER); widgets.enable(); diff --git a/picocli-shell-jline3/src/test/java/picocli/shell/jline3/example/Example.java b/picocli-shell-jline3/src/test/java/picocli/shell/jline3/example/Example.java index b00cdb4d5..7d3ff6d44 100644 --- a/picocli-shell-jline3/src/test/java/picocli/shell/jline3/example/Example.java +++ b/picocli-shell-jline3/src/test/java/picocli/shell/jline3/example/Example.java @@ -51,6 +51,10 @@ static class CliCommands implements Runnable { CliCommands() {} + public void setReader(LineReader reader){ + out = reader.getTerminal().writer(); + } + public void run() { out.println(new CommandLine(this).getUsageMessage()); } @@ -158,6 +162,7 @@ public static void main(String[] args) { .variable(LineReader.LIST_MAX, 50) // max tab completion candidates .build(); builtins.setLineReader(reader); + commands.setReader(reader); factory.setTerminal(terminal); TailTipWidgets widgets = new TailTipWidgets(reader, systemRegistry::commandDescription, 5, TailTipWidgets.TipType.COMPLETER); widgets.enable();