Skip to content

Commit

Permalink
ISSUE1175 : Update JLine to 3.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rnc authored and remkop committed Sep 19, 2020
1 parent ff7ed37 commit 28bac6a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ivyVersion = 2.4.0
jacocoVersion = 0.8.2
jansiVersion = 1.15
jlineVersion = 2.14.6
jline3Version = 3.15.0
jline3Version = 3.16.0
junitDepVersion = 4.11
junitVersion = 4.12
springBootVersion = 2.2.2.RELEASE
Expand Down
1 change: 1 addition & 0 deletions picocli-shell-jline3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ targetCompatibility = 1.8
dependencies {
compile rootProject
compile "org.jline:jline:$jline3Version"
compile "org.jline:jline-console:$jline3Version"
testCompile "junit:junit:$junitVersion"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ public List<String> commandInfo(String command) {
return out;
}

// For JLine >= 3.16.0
@Override
public Object invoke(CommandRegistry.CommandSession session, String command, Object[] args) throws Exception {
List<String> arguments = new ArrayList<>();
arguments.add( command );
arguments.addAll( Arrays.stream( args ).map( Object::toString ).collect( Collectors.toList() ) );
cmd.execute( arguments.toArray( new String[0] ) );
return null;
}

// @Override This method was removed in JLine 3.16.0; keep it in case this component is used with an older version of JLine
public Object execute(CommandRegistry.CommandSession session, String command, String[] args) throws Exception {
List<String> arguments = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
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 Down Expand Up @@ -153,7 +152,7 @@ public static void main(String[] args) {
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 @@ -174,7 +173,8 @@ public static void main(String[] args) {
.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

0 comments on commit 28bac6a

Please sign in to comment.