This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new ab9e90b remove echo in cli (#1287)
ab9e90b is described below
commit ab9e90be5dbaa1aba6254dcf5ab160239867dd69
Author: Ring-k <[email protected]>
AuthorDate: Sun May 31 12:27:16 2020 +0800
remove echo in cli (#1287)
* remove duplicate echo in Cli
---
cli/src/main/java/org/apache/iotdb/cli/Cli.java | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/cli/src/main/java/org/apache/iotdb/cli/Cli.java
b/cli/src/main/java/org/apache/iotdb/cli/Cli.java
index dc0e967..27f5a53 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/Cli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/Cli.java
@@ -18,10 +18,9 @@
*/
package org.apache.iotdb.cli;
-import java.io.IOException;
import java.sql.DriverManager;
import java.sql.SQLException;
-import jline.console.ConsoleReader;
+import java.util.Scanner;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
@@ -108,16 +107,15 @@ public class Cli extends AbstractCli {
}
private static void serve() {
- try (ConsoleReader reader = new ConsoleReader()) {
- reader.setExpandEvents(false);
-
+ try (Scanner scanner = new Scanner(System.in)) {
host = checkRequiredArg(HOST_ARGS, HOST_NAME, commandLine, false, host);
port = checkRequiredArg(PORT_ARGS, PORT_NAME, commandLine, false, port);
username = checkRequiredArg(USERNAME_ARGS, USERNAME_NAME, commandLine,
true, null);
password = commandLine.getOptionValue(PASSWORD_ARGS);
if (password == null) {
- password = reader.readLine("please input your password:", '\0');
+ print("please input your password:");
+ password = scanner.nextLine();
}
if (hasExecuteSQL) {
try (IoTDBConnection connection = (IoTDBConnection) DriverManager
@@ -131,7 +129,7 @@ public class Cli extends AbstractCli {
}
}
- receiveCommands(reader);
+ receiveCommands(scanner);
} catch (ArgsErrorException e) {
println(IOTDB_CLI_PREFIX + "> input params error because" +
e.getMessage());
} catch (Exception e) {
@@ -139,7 +137,7 @@ public class Cli extends AbstractCli {
}
}
- private static void receiveCommands(ConsoleReader reader) throws TException,
IOException {
+ private static void receiveCommands(Scanner scanner) throws TException {
try (IoTDBConnection connection = (IoTDBConnection) DriverManager
.getConnection(Config.IOTDB_URL_PREFIX + host + ":" + port + "/",
username, password)) {
String s;
@@ -151,7 +149,8 @@ public class Cli extends AbstractCli {
displayLogo(properties.getVersion());
println(IOTDB_CLI_PREFIX + "> login successfully");
while (true) {
- s = reader.readLine(IOTDB_CLI_PREFIX + "> ", null);
+ print(IOTDB_CLI_PREFIX + "> ");
+ s = scanner.nextLine();
boolean continues = processCommand(s, connection);
if (!continues) {
break;