Skip to content
This repository was archived by the owner on Dec 15, 2023. It is now read-only.

Commit 5009a0b

Browse files
committed
fix: conf issue
1 parent 337426f commit 5009a0b

File tree

3 files changed

+66
-56
lines changed

3 files changed

+66
-56
lines changed

src/cmd.rs

+24-19
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ impl Cli {
4040
match sub_cmd {
4141
// exec sql form file
4242
SubCmd::File { file_path } => {
43-
if let Some(file_path) = file_path {
44-
common::exec_batch_from_file(conf, file_path);
43+
if let Some(file) = file_path {
44+
common::exec_batch_from_file(conf, file);
4545
}
4646
}
4747
SubCmd::Usage => sub_cmd.usage(),
@@ -57,6 +57,7 @@ impl Cli {
5757
/// Set session conf
5858
pub fn session_conf(&self) -> Config {
5959
let Cli {
60+
dev,
6061
host,
6162
port,
6263
user,
@@ -68,30 +69,34 @@ impl Cli {
6869
} = self;
6970

7071
let mut builder = ConfigBuilder::new();
71-
// enable debug mode
72-
builder.debug(*debug);
7372

74-
// set endpoint
75-
if let Some(endpoint) = endpoint {
76-
let endpoint = endpoint.as_str().parse::<Endpoint>().unwrap();
77-
builder.endpoint(endpoint.host.as_str(), endpoint.port.as_str());
78-
} else if let Some(host) = host {
79-
if let Some(port) = port {
80-
builder.endpoint(host.as_str(), port.as_str());
81-
}
73+
// timezone
74+
if let Some(timezone) = timezone {
75+
builder.time_zone(timezone.as_str());
8276
}
8377

78+
// enable debug mode
79+
builder.debug(*debug);
80+
8481
// user and password
8582
if let Some(user) = user {
86-
if let Some(password) = password {
87-
builder.user(user.as_str());
88-
builder.password(password.as_str());
89-
}
83+
builder.user(user.as_str());
84+
}
85+
if let Some(password) = password {
86+
builder.password(password.as_str());
9087
}
9188

92-
// timezone
93-
if let Some(timezone) = timezone {
94-
builder.time_zone(timezone.as_str());
89+
// set endpoint
90+
if host.is_some() && port.is_some() {
91+
builder.endpoint(
92+
host.as_ref().unwrap().as_str(),
93+
port.as_ref().unwrap().as_str(),
94+
);
95+
} else if let Some(endpoint) = endpoint {
96+
let endpoint = endpoint.as_str().parse::<Endpoint>().unwrap();
97+
builder.endpoint(endpoint.host.as_str(), endpoint.port.as_str());
98+
} else if *dev {
99+
builder.endpoint("119.84.128.59", "6667");
95100
}
96101

97102
builder.build()

src/opt.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ use crate::{ASCII_NAME, AUTHORS, PKG_NAME};
22
use structopt::StructOpt;
33

44
#[derive(Debug, Clone, StructOpt)]
5-
#[structopt(name = format ! ("{}\nAuthor: {}\nVersion: {}", ASCII_NAME, AUTHORS, PKG_NAME))]
5+
#[structopt(name = format!("{}\nAuthor: {}\nVersion: {}", ASCII_NAME, AUTHORS, PKG_NAME))]
66
pub struct Cli {
77
/// Execute single sql, eg: `iotdb "show storage group"`
88
pub sql: Option<String>,
99

10+
/// Dev server
11+
#[structopt(long)]
12+
pub dev: bool,
13+
1014
/// Execute batch form sql file, eg: `iotdb -f ddl.sql`
1115
#[structopt(short = "f", long)]
1216
pub file: Option<String>,
@@ -51,6 +55,7 @@ impl Cli {
5155
}
5256

5357
#[derive(Debug, Clone, StructOpt)]
58+
#[structopt(name = format ! ("{}\nAuthor: {}\nVersion: {}", ASCII_NAME, AUTHORS, PKG_NAME))]
5459
pub enum SubCmd {
5560
/// Execute batch form sql file, eg: `iotdb file ddl.sql`
5661
File { file_path: Option<String> },
@@ -64,13 +69,13 @@ pub enum SubCmd {
6469
export: Option<String>,
6570
},
6671

67-
/// Load TsFile util(TODO)
72+
/// Load TsFile util (TODO)
6873
Load,
6974

7075
/// Print usage info
7176
Usage,
7277

73-
/// Update binary(TODO)
78+
/// Update binary (TODO)
7479
Update,
7580

7681
/// Prints version information

src/static/usage_info

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
Usage info:
2-
DDL & DQL:
1+
usage info:
2+
ddl & dql:
33
01. `set storage group to root.ln`
44
02. `show storage group` | `show storage group root.*`
5-
03. `DELETE STORAGE GROUP root.ln` | `DELETE STORAGE GROUP root.*`
6-
04. `create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN`
7-
05. `CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT encoding=PLAIN compressor=SNAPPY, longitude FLOAT encoding=PLAIN compressor=SNAPPY)`
5+
03. `delete storage group root.ln` | `delete storage group root.*`
6+
04. `create timeseries root.ln.wf01.wt01.status with datatype=boolean,encoding=plain`
7+
05. `create aligned timeseries root.ln.wf01.gps(latitude float encoding=plain compressor=snappy, longitude float encoding=plain compressor=snappy)`
88
06. `delete timeseries root.ln.wf01.wt01.status` | `delete timeseries root.ln.wf01.wt01.*`
99
07. `show timeseries root.*`
10-
08. `COUNT TIMESERIES root.*`
11-
09. `SHOW CHILD PATHS pathPattern`
12-
10. `SHOW CHILD NODES pathPattern`
13-
11. `COUNT NODES root.** LEVEL=2`
10+
08. `count timeseries root.*`
11+
09. `show child paths pathpattern`
12+
10. `show child nodes pathpattern`
13+
11. `count nodes root.** level=2`
1414
12. `show devices` | `show devices root.ln.*`
15-
13. `create schema template temp1(GPS(lat FLOAT encoding=Gorilla, lon FLOAT encoding=Gorilla) compression=SNAPPY, status BOOLEAN encoding=PLAIN compression=SNAPPY)`
15+
13. `create schema template temp1(gps(lat float encoding=gorilla, lon float encoding=gorilla) compression=snappy, status boolean encoding=plain compression=snappy)`
1616
14. `set schema template temp1 to root.ln.wf01`
1717
15. `unset schema template temp1 from root.beijing`
1818
16. `set ttl to root.ln 3600000`
1919
17. `unset ttl to root.ln`
20-
18. `SHOW ALL TTL` | `SHOW TTL ON StorageGroupNames`
21-
DML:
20+
18. `show all ttl` | `show ttl on storagegroupnames`
21+
dml:
2222
01. `insert into root.ln.wf02.wt02(timestamp,status) values(1,true)`
23-
02. `select temperature from root.ln.wf01.wt01 where time < 2017-11-01T00:08:00.000`
23+
02. `select temperature from root.ln.wf01.wt01 where time < 2017-11-01t00:08:00.000`
2424
03. `select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1`
2525
04. `select count(status) from root.ln.wf01.wt01`
26-
05. `select <path> from <prefixPath> where time = <T> fill(<data_type>[previous, <before_range>], …)`
27-
06. `select last <Path> [COMMA <Path>]* from < PrefixPath > [COMMA < PrefixPath >]* <WhereClause>`
26+
05. `select <path> from <prefixpath> where time = <t> fill(<data_type>[previous, <before_range>], …)`
27+
06. `select last <path> [comma <path>]* from < prefixpath > [comma < prefixpath >]* <whereclause>`
2828
07. `select * from root.sg.device where value like '%cc%'`
2929
08. `select s1 as temperature, s2 as speed from root.ln.wf01.wt01`
3030
09. `select status, temperature from root.ln.wf01.wt01 limit 10`
31-
10. `select * from root.ln.* where time <= 2017-11-01T00:01:00 WITHOUT NULL ANY`
32-
11. `select * from root.ln.* where time <= 2017-11-01T00:01:00 align by device`
33-
12. `delete from root.ln.wf02.wt02.status where time<=2017-11-01T16:26:00`
34-
13. `delete from root.ln.wf02.wt02 where time <= 2017-11-01T16:26:00`
35-
14. `DELETE PARTITION root.ln 0,1,2`
36-
Other:
37-
01. `FLUSH` | `FLUSH root.ln`
38-
02. `MERGE` | `FULL MERGE`
39-
03. `CLEAR CACHE`
40-
04. `SET SYSTEM TO READONLY`
41-
05. `CREATE SNAPSHOT FOR SCHEMA`
42-
06. `KILL QUERY <queryId>`
43-
Useful links:
44-
01. What is IoTDB: https://iotdb.apache.org/UserGuide/Master/IoTDB-Introduction/What-is-IoTDB.html
45-
02. SQL guide: https://iotdb.apache.org/UserGuide/Master/IoTDB-SQL-Language/DDL-Data-Definition-Language.html
46-
03. Data concept: https://iotdb.apache.org/UserGuide/Master/Data-Concept/Data-Model-and-Terminology.html
47-
04. Advanced features: https://iotdb.apache.org/UserGuide/Master/Advanced-Features/UDF-User-Defined-Function.html
48-
04. About iotdb-rs: https://github.com/francis-du/iotdb-rs
49-
05. About iotdb-cli: https://github.com/francis-du/iotdb-cli
31+
10. `select * from root.ln.* where time <= 2017-11-01t00:01:00 without null any`
32+
11. `select * from root.ln.* where time <= 2017-11-01t00:01:00 align by device`
33+
12. `delete from root.ln.wf02.wt02.status where time<=2017-11-01t16:26:00`
34+
13. `delete from root.ln.wf02.wt02 where time <= 2017-11-01t16:26:00`
35+
14. `delete partition root.ln 0,1,2`
36+
other:
37+
01. `flush` | `flush root.ln`
38+
02. `merge` | `full merge`
39+
03. `clear cache`
40+
04. `set system to readonly`
41+
05. `create snapshot for schema`
42+
06. `kill query <queryid>`
43+
useful links:
44+
01. what is iotdb: https://iotdb.apache.org/userguide/master/iotdb-introduction/what-is-iotdb.html
45+
02. sql guide: https://iotdb.apache.org/userguide/master/iotdb-sql-language/ddl-data-definition-language.html
46+
03. data concept: https://iotdb.apache.org/userguide/master/data-concept/data-model-and-terminology.html
47+
04. advanced features: https://iotdb.apache.org/userguide/master/advanced-features/udf-user-defined-function.html
48+
04. about iotdb-rs: https://github.com/francis-du/iotdb-rs
49+
05. about iotdb-cli: https://github.com/francis-du/iotdb-cli

0 commit comments

Comments
 (0)