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 298e9ad [IOTDB-664]Win -e option (#1195)
298e9ad is described below
commit 298e9ade935e81df8c55eff81f6924d2bb588fb6
Author: gwmh <[email protected]>
AuthorDate: Wed May 13 10:05:33 2020 +0800
[IOTDB-664]Win -e option (#1195)
* add win -e option
---
cli/src/assembly/resources/sbin/start-cli.bat | 3 ---
cli/src/main/java/org/apache/iotdb/cli/WinCli.java | 19 ++++++++++++++++---
.../org/apache/iotdb/cli/StartClientScriptIT.java | 3 +--
docs/UserGuide/4-Client/1-Command Line Interface.md | 11 ++++++++++-
.../zh/UserGuide/4-Client/1-Command Line Interface.md | 11 ++++++++++-
5 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/cli/src/assembly/resources/sbin/start-cli.bat
b/cli/src/assembly/resources/sbin/start-cli.bat
index 56ef9c2..264b801 100644
--- a/cli/src/assembly/resources/sbin/start-cli.bat
+++ b/cli/src/assembly/resources/sbin/start-cli.bat
@@ -18,9 +18,6 @@
@REM
@echo off
-echo ````````````````````````
-echo Starting IoTDB Cli
-echo ````````````````````````
@REM You can put your env variable here
@REM set JAVA_HOME=%JAVA_HOME%
diff --git a/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
b/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
index 97b6a43..121d912 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
@@ -53,6 +53,7 @@ public class WinCli extends AbstractCli {
commandLine = null;
String[] newArgs;
+ String[] newArgs2;
if (args == null || args.length == 0) {
println("Require more params input, please check the following hint.");
@@ -61,10 +62,9 @@ public class WinCli extends AbstractCli {
}
init();
-
newArgs = removePasswordArgs(args);
-
- boolean continues = parseCommandLine(options, newArgs, hf);
+ newArgs2 = processExecuteArgs(newArgs);
+ boolean continues = parseCommandLine(options, newArgs2, hf);
if (!continues) {
return;
}
@@ -124,6 +124,18 @@ public class WinCli extends AbstractCli {
if (password == null) {
password = readPassword();
}
+ if (hasExecuteSQL) {
+ try (IoTDBConnection connection = (IoTDBConnection) DriverManager
+ .getConnection(Config.IOTDB_URL_PREFIX + host + ":" + port + "/",
username, password)) {
+ properties = connection.getServerProperties();
+
AGGREGRATE_TIME_LIST.addAll(properties.getSupportedTimeAggregationOperations());
+ processCommand(execute, connection);
+ return;
+ } catch (SQLException e) {
+ println(IOTDB_CLI_PREFIX + "> can't execute sql because" +
e.getMessage());
+ }
+ }
+
receiveCommands(scanner);
} catch (ArgsErrorException e) {
println(IOTDB_CLI_PREFIX + "> input params error because" +
e.getMessage());
@@ -139,6 +151,7 @@ public class WinCli extends AbstractCli {
AGGREGRATE_TIME_LIST.addAll(properties.getSupportedTimeAggregationOperations());
TIMESTAMP_PRECISION = properties.getTimestampPrecision();
+ echoStarting();
displayLogo(properties.getVersion());
println(IOTDB_CLI_PREFIX + "> login successfully");
while (true) {
diff --git a/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
b/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
index 50b7eec..39397d5 100644
--- a/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
+++ b/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
@@ -47,8 +47,7 @@ public class StartClientScriptIT extends AbstractScript {
@Override
protected void testOnWindows() throws IOException {
- final String[] output = {"````````````````````````", "Starting IoTDB Cli",
- "````````````````````````",
+ final String[] output = {
"IoTDB> Connection Error, please check whether the network is
available or the server has started. Host is 127.0.0.1, port is 6668."};
String dir = getCliPath();
ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c",
diff --git a/docs/UserGuide/4-Client/1-Command Line Interface.md
b/docs/UserGuide/4-Client/1-Command Line Interface.md
index 10472d3..7b03398 100644
--- a/docs/UserGuide/4-Client/1-Command Line Interface.md
+++ b/docs/UserGuide/4-Client/1-Command Line Interface.md
@@ -113,11 +113,20 @@ In order to avoid confusion between statements and other
parameters, the current
The usage of -e parameter for Cli/shell is as follows:
+The Linux and MacOS system commands:
+
```
Shell > sbin/start-cli.sh -h {host} -p {port} -u {user} -pw {password} -e
{sql for iotdb}
```
-In order to better explain the use of -e parameter, take following as an
example.
+The Windows system commands:
+```
+ Shell > sbin\start-cli.bat -h {host} -p {port} -u {user} -pw {password} -e
{sql for iotdb}
+```
+
+In the Windows environment, the SQL statement of the -e parameter needs to use
` `` ` to replace `" "`
+
+In order to better explain the use of -e parameter, take following as an
example(On linux system).
Suppose you want to create a storage group root.demo to a newly launched
IoTDB, create a timeseries root.demo.s1 and insert three data points into it.
With -e parameter, you could write a shell like this:
diff --git a/docs/zh/UserGuide/4-Client/1-Command Line Interface.md
b/docs/zh/UserGuide/4-Client/1-Command Line Interface.md
index d59bec0..15fd54d 100644
--- a/docs/zh/UserGuide/4-Client/1-Command Line Interface.md
+++ b/docs/zh/UserGuide/4-Client/1-Command Line Interface.md
@@ -109,11 +109,20 @@ Windows系统启动命令如下:
针对cli/Shell工具的-e参数用法如下:
+Linux系统与MacOS指令:
+
```
Shell > sbin/start-cli.sh -h {host} -p {port} -u {user} -pw {password} -e
{sql for iotdb}
```
-为了更好的解释-e参数的使用,可以参考下面的例子。
+Windows系统指令
+```
+ Shell > sbin\start-cli.bat -h {host} -p {port} -u {user} -pw {password} -e
{sql for iotdb}
+```
+
+在Windows环境下,-e参数的SQL语句需要使用` `` `对于`" "`进行替换
+
+为了更好的解释-e参数的使用,可以参考下面在Linux上执行的例子。
假设用户希望对一个新启动的IoTDB进行如下操作: