update jline to 2.14
This commit is contained in:
parent
ff67ca8c96
commit
b0896912a1
@ -58,7 +58,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jline</groupId>
|
<groupId>jline</groupId>
|
||||||
<artifactId>jline</artifactId>
|
<artifactId>jline</artifactId>
|
||||||
<version>1.0</version>
|
<version>2.14.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-cli</groupId>
|
<groupId>commons-cli</groupId>
|
||||||
|
@ -26,7 +26,10 @@ public class Main {
|
|||||||
if (file != null && file.length() > 0) {
|
if (file != null && file.length() > 0) {
|
||||||
if ("-".equals(file)) {
|
if ("-".equals(file)) {
|
||||||
scriptClient.execute(new InputStreamReader(System.in));
|
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 {
|
} else {
|
||||||
BufferedReader bufferedReader = null;
|
BufferedReader bufferedReader = null;
|
||||||
try {
|
try {
|
||||||
@ -58,14 +61,20 @@ public class Main {
|
|||||||
final String expr = cmdParser.getExpression();
|
final String expr = cmdParser.getExpression();
|
||||||
if (expr != null && expr.length() > 0) {
|
if (expr != null && expr.length() > 0) {
|
||||||
scriptClient.execute(expr);
|
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()) {
|
if (cmdParser.isInteractive()) {
|
||||||
String command = console.readInput();
|
String command = console.readInput();
|
||||||
while (!isExitCommand(command)) {
|
while (!isExitCommand(command)) {
|
||||||
try {
|
try {
|
||||||
scriptClient.execute(command);
|
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) {
|
} catch (JSCliException e) {
|
||||||
console.println(findRootException(e) + "\n");
|
console.println(findRootException(e) + "\n");
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package de.hsadmin.jscli.console;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import jline.ConsoleReader;
|
|
||||||
import jline.History;
|
|
||||||
import jline.SimpleCompletor;
|
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
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 {
|
public class ConsoleWrapper implements PasswordReader {
|
||||||
|
|
||||||
@ -17,9 +17,9 @@ public class ConsoleWrapper implements PasswordReader {
|
|||||||
this.prompt = prompt;
|
this.prompt = prompt;
|
||||||
try {
|
try {
|
||||||
cons = new ConsoleReader();
|
cons = new ConsoleReader();
|
||||||
cons.setDefaultPrompt(prompt);
|
cons.setPrompt(prompt);
|
||||||
final String userHome = System.getProperty("user.home");
|
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) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new JSCliException(e);
|
||||||
}
|
}
|
||||||
@ -40,8 +40,7 @@ public class ConsoleWrapper implements PasswordReader {
|
|||||||
public void println(final String text) throws JSCliException {
|
public void println(final String text) throws JSCliException {
|
||||||
try {
|
try {
|
||||||
if (cons != null) {
|
if (cons != null) {
|
||||||
cons.printString(text);
|
cons.println(text);
|
||||||
cons.printNewline();
|
|
||||||
} else {
|
} else {
|
||||||
throw new JSCliException("cannot write console");
|
throw new JSCliException("cannot write console");
|
||||||
}
|
}
|
||||||
@ -53,7 +52,7 @@ public class ConsoleWrapper implements PasswordReader {
|
|||||||
public String readPassword() throws JSCliException {
|
public String readPassword() throws JSCliException {
|
||||||
try {
|
try {
|
||||||
final String pw = cons.readLine("Password: ", new Character('*'));
|
final String pw = cons.readLine("Password: ", new Character('*'));
|
||||||
cons.setDefaultPrompt(prompt);
|
cons.setPrompt(prompt);
|
||||||
return pw;
|
return pw;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new JSCliException(e);
|
||||||
@ -61,7 +60,7 @@ public class ConsoleWrapper implements PasswordReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void codeCompletion(final String[] candidateStrings) {
|
public void codeCompletion(final String[] candidateStrings) {
|
||||||
cons.addCompletor(new SimpleCompletor(candidateStrings));
|
cons.addCompleter(new StringsCompleter(candidateStrings));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public class JSONFormatter {
|
|||||||
if (ind > 52) {
|
if (ind > 52) {
|
||||||
ind = 52;
|
ind = 52;
|
||||||
}
|
}
|
||||||
return "\n ".substring(0, indent);
|
return "\n ".substring(0, ind);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user