From 4f22928f6c19e89110b67f7785b4993503853ae2 Mon Sep 17 00:00:00 2001 From: Remko Popma Date: Sun, 20 Sep 2020 08:36:55 +0900 Subject: [PATCH] [#1176] DOC: Update JLine `picocli-shell-jline3` example to 3.16.0 --- RELEASE-NOTES.md | 2 ++ picocli-shell-jline3/README.md | 26 ++++++++++++------- .../picocli/shell/jline3/example/Example.java | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 8e8c60eb..f877e180 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -35,6 +35,8 @@ Picocli follows [semantic versioning](http://semver.org/). * [#1179] TEST: Use `.invalid` domain name for `InetAddress` test. Thanks to [David Phillips](https://github.com/electrum) for the pull request. * [#1178] BUILD: Run Travis build on macOS. Thanks to [David Phillips](https://github.com/electrum) for the pull request. * [#1175] DOC: section on compatible versions to `picocli-shell-jline3/README.md`. Thanks to [Nick Cross](https://github.com/rnc) for raising this. +* [#1176] DOC: Update JLine `picocli-shell-jline3` example to 3.16.0. Thanks to [Nick Cross](https://github.com/rnc) for the pull request. + ## Deprecations No features were deprecated in this release. diff --git a/picocli-shell-jline3/README.md b/picocli-shell-jline3/README.md index d9180ad6..55bf8bf8 100644 --- a/picocli-shell-jline3/README.md +++ b/picocli-shell-jline3/README.md @@ -67,25 +67,30 @@ JLine [Wiki](https://github.com/jline/jline3/wiki) and some more [Demos](https:/ ## Example -The following example requires JLine 3.15+ and Picocli 4.4+. +### Older versions See examples for older versions on the [wiki](https://github.com/remkop/picocli/wiki/JLine-3-Examples). +* [Example for JLine 3.13.2 and Picocli 4.1.2](https://github.com/remkop/picocli/wiki/JLine-3-Examples#example-for-jline-3132-and-picocli-412) +* [Example for JLine 3.14.1 and Picocli 4.3.0 - 4.3.2](https://github.com/remkop/picocli/wiki/JLine-3-Examples#example-for-jline-3141-and-picocli-430---432) +* [Example for JLine 3.15 and Picocli 4.4+](https://github.com/remkop/picocli/wiki/JLine-3-Examples#example-for-jline-315-and-picocli-44) + +### JLine 3.16 and Picocli 4.4+ Example + ```java package picocli.shell.jline3.example; import org.fusesource.jansi.AnsiConsole; -import org.jline.builtins.Builtins; -import org.jline.builtins.Widgets.TailTipWidgets; -import org.jline.builtins.Widgets.TailTipWidgets.TipType; +import org.jline.console.SystemRegistry; +import org.jline.console.impl.Builtins; +import org.jline.console.impl.SystemRegistryImpl; import org.jline.keymap.KeyMap; -import org.jline.builtins.SystemRegistry; -import org.jline.builtins.SystemRegistryImpl; import org.jline.reader.*; import org.jline.reader.impl.DefaultParser; import org.jline.reader.impl.LineReaderImpl; import org.jline.terminal.Terminal; import org.jline.terminal.TerminalBuilder; +import org.jline.widget.TailTipWidgets; import picocli.CommandLine; import picocli.CommandLine.ArgGroup; import picocli.CommandLine.Command; @@ -102,7 +107,7 @@ import java.util.concurrent.TimeUnit; /** * Example that demonstrates how to build an interactive shell with JLine3 and picocli. - * @since 4.5.1 + * This example requires JLine 3.16+ and picocli 4.4+. */ public class Example { @@ -227,7 +232,7 @@ public class Example { try { // set up JLine built-in commands Builtins builtins = new Builtins(Example::workDir, null, null); - builtins.rename(org.jline.builtins.Builtins.Command.TTOP, "top"); + builtins.rename(Builtins.Command.TTOP, "top"); builtins.alias("zle", "widget"); builtins.alias("bindkey", "keymap"); // set up picocli commands @@ -248,7 +253,8 @@ public class Example { .build(); builtins.setLineReader(reader); commands.setReader(reader); - new TailTipWidgets(reader, systemRegistry::commandDescription, 5, TipType.COMPLETER); + TailTipWidgets widgets = new TailTipWidgets(reader, systemRegistry::commandDescription, 5, TailTipWidgets.TipType.COMPLETER); + widgets.enable(); KeyMap keyMap = reader.getKeyMaps().get("main"); keyMap.bind(new Reference("tailtip-toggle"), KeyMap.alt("s")); @@ -278,4 +284,4 @@ public class Example { } } } -``` +``` \ No newline at end of file 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 6c94f612..6ed8cc05 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 @@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit; /** * Example that demonstrates how to build an interactive shell with JLine3 and picocli. - * @since 4.3.2 + * This example requires JLine 3.16+ and picocli 4.4+. */ public class Example {