Skip to content

Commit

Permalink
[#1176] DOC: Update JLine picocli-shell-jline3 example to 3.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Sep 19, 2020
1 parent 28bac6a commit 4f22928
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 2 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


## <a name="4.5.2-deprecated"></a> Deprecations
No features were deprecated in this release.
Expand Down
26 changes: 16 additions & 10 deletions picocli-shell-jline3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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
Expand All @@ -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<Binding> keyMap = reader.getKeyMaps().get("main");
keyMap.bind(new Reference("tailtip-toggle"), KeyMap.alt("s"));

Expand Down Expand Up @@ -278,4 +284,4 @@ public class Example {
}
}
}
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/**
* 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 {

Expand Down

0 comments on commit 4f22928

Please sign in to comment.