diff --git a/cli/pom.xml b/cli/pom.xml
index 183e3a4..41cd535 100644
--- a/cli/pom.xml
+++ b/cli/pom.xml
@@ -58,7 +58,7 @@
jline
jline
- 1.0
+ 2.14.2
commons-cli
diff --git a/cli/src/main/java/de/hsadmin/jscli/Main.java b/cli/src/main/java/de/hsadmin/jscli/Main.java
index b167754..ceb6f70 100644
--- a/cli/src/main/java/de/hsadmin/jscli/Main.java
+++ b/cli/src/main/java/de/hsadmin/jscli/Main.java
@@ -26,7 +26,10 @@ public class Main {
if (file != null && file.length() > 0) {
if ("-".equals(file)) {
scriptClient.execute(new InputStreamReader(System.in));
- console.println(formatter.format(scriptClient.getLastRpcResult()));
+ final String[] lines = formatter.format(scriptClient.getLastRpcResult()).split("\n");
+ for (String ll : lines) {
+ console.println(ll);
+ }
} else {
BufferedReader bufferedReader = null;
try {
@@ -58,14 +61,20 @@ public class Main {
final String expr = cmdParser.getExpression();
if (expr != null && expr.length() > 0) {
scriptClient.execute(expr);
- console.println(formatter.format(scriptClient.getLastRpcResult()));
+ final String[] lines = formatter.format(scriptClient.getLastRpcResult()).split("\n");
+ for (String ll : lines) {
+ console.println(ll);
+ }
}
if (cmdParser.isInteractive()) {
String command = console.readInput();
while (!isExitCommand(command)) {
try {
scriptClient.execute(command);
- console.println(formatter.format(scriptClient.getLastRpcResult()));
+ final String[] lines = formatter.format(scriptClient.getLastRpcResult()).split("\n");
+ for (String ll : lines) {
+ console.println(ll);
+ }
} catch (JSCliException e) {
console.println(findRootException(e) + "\n");
}
diff --git a/cli/src/main/java/de/hsadmin/jscli/console/ConsoleWrapper.java b/cli/src/main/java/de/hsadmin/jscli/console/ConsoleWrapper.java
index 1715ec2..8ccd18b 100644
--- a/cli/src/main/java/de/hsadmin/jscli/console/ConsoleWrapper.java
+++ b/cli/src/main/java/de/hsadmin/jscli/console/ConsoleWrapper.java
@@ -3,10 +3,10 @@ package de.hsadmin.jscli.console;
import java.io.File;
import java.io.IOException;
-import jline.ConsoleReader;
-import jline.History;
-import jline.SimpleCompletor;
import de.hsadmin.jscli.exception.JSCliException;
+import jline.console.ConsoleReader;
+import jline.console.completer.StringsCompleter;
+import jline.console.history.FileHistory;
public class ConsoleWrapper implements PasswordReader {
@@ -17,9 +17,9 @@ public class ConsoleWrapper implements PasswordReader {
this.prompt = prompt;
try {
cons = new ConsoleReader();
- cons.setDefaultPrompt(prompt);
+ cons.setPrompt(prompt);
final String userHome = System.getProperty("user.home");
- cons.setHistory(new History(new File(userHome + "/.hsscript_history")));
+ cons.setHistory(new FileHistory(new File(userHome + "/.hsscript_history")));
} catch (IOException e) {
throw new JSCliException(e);
}
@@ -40,8 +40,7 @@ public class ConsoleWrapper implements PasswordReader {
public void println(final String text) throws JSCliException {
try {
if (cons != null) {
- cons.printString(text);
- cons.printNewline();
+ cons.println(text);
} else {
throw new JSCliException("cannot write console");
}
@@ -53,7 +52,7 @@ public class ConsoleWrapper implements PasswordReader {
public String readPassword() throws JSCliException {
try {
final String pw = cons.readLine("Password: ", new Character('*'));
- cons.setDefaultPrompt(prompt);
+ cons.setPrompt(prompt);
return pw;
} catch (IOException e) {
throw new JSCliException(e);
@@ -61,7 +60,7 @@ public class ConsoleWrapper implements PasswordReader {
}
public void codeCompletion(final String[] candidateStrings) {
- cons.addCompletor(new SimpleCompletor(candidateStrings));
+ cons.addCompleter(new StringsCompleter(candidateStrings));
}
}
diff --git a/cli/src/main/java/de/hsadmin/jscli/json/JSONFormatter.java b/cli/src/main/java/de/hsadmin/jscli/json/JSONFormatter.java
index 35a27cb..3644a78 100644
--- a/cli/src/main/java/de/hsadmin/jscli/json/JSONFormatter.java
+++ b/cli/src/main/java/de/hsadmin/jscli/json/JSONFormatter.java
@@ -98,7 +98,7 @@ public class JSONFormatter {
if (ind > 52) {
ind = 52;
}
- return "\n ".substring(0, indent);
+ return "\n ".substring(0, ind);
}
}