feat: auto append end char ; to command
This commit is contained in:
parent
736149daea
commit
b5e6c55749
|
@ -46,6 +46,7 @@ typedef struct SWord {
|
|||
int32_t len;
|
||||
struct SWord* next;
|
||||
bool free; // if true need free
|
||||
bool end; // if true is last keyword
|
||||
} SWord;
|
||||
|
||||
typedef struct {
|
||||
|
@ -101,22 +102,22 @@ SWords shellCommands[] = {
|
|||
{"create topic <anyword> as select", 0, 0, NULL}, // 27 append sub sql
|
||||
{"create tsma <anyword> on <all_table> function", 0, 0, NULL},
|
||||
{"create recursive tsma <anyword> on <tsma_name> interval(", 0, 0, NULL},
|
||||
{"create function <anyword> as <anyword> outputtype <data_types> language <udf_language>", 0, 0, NULL},
|
||||
{"create or replace <anyword> as <anyword> outputtype <data_types> language <udf_language>", 0, 0, NULL},
|
||||
{"create aggregate function <anyword> as <anyword> outputtype <data_types> bufsize <anyword> language <udf_language>", 0, 0, NULL},
|
||||
{"create or replace aggregate function <anyword> as <anyword> outputtype <data_types> bufsize <anyword> language <udf_language>", 0, 0, NULL},
|
||||
{"create function <anyword> as <anyword> outputtype <data_types> language <udf_language>;", 0, 0, NULL},
|
||||
{"create or replace <anyword> as <anyword> outputtype <data_types> language <udf_language>;", 0, 0, NULL},
|
||||
{"create aggregate function <anyword> as <anyword> outputtype <data_types> bufsize <anyword> language <udf_language>;", 0, 0, NULL},
|
||||
{"create or replace aggregate function <anyword> as <anyword> outputtype <data_types> bufsize <anyword> language <udf_language>;", 0, 0, NULL},
|
||||
{"create user <anyword> pass <anyword> sysinfo 0;", 0, 0, NULL},
|
||||
{"create user <anyword> pass <anyword> sysinfo 1;", 0, 0, NULL},
|
||||
#ifdef TD_ENTERPRISE
|
||||
{"create view <anyword> as select", 0, 0, NULL},
|
||||
{"compact database <db_name>", 0, 0, NULL},
|
||||
#endif
|
||||
{"describe <all_table>", 0, 0, NULL},
|
||||
{"describe <all_table>;", 0, 0, NULL},
|
||||
{"delete from <all_table> where ", 0, 0, NULL},
|
||||
{"drop database <db_name>", 0, 0, NULL},
|
||||
{"drop index <anyword>", 0, 0, NULL},
|
||||
{"drop table <all_table>", 0, 0, NULL},
|
||||
{"drop dnode <dnode_id>", 0, 0, NULL},
|
||||
{"drop database <db_name>;", 0, 0, NULL},
|
||||
{"drop index <anyword>;", 0, 0, NULL},
|
||||
{"drop table <all_table>;", 0, 0, NULL},
|
||||
{"drop dnode <dnode_id>;", 0, 0, NULL},
|
||||
{"drop mnode on dnode <dnode_id>;", 0, 0, NULL},
|
||||
{"drop qnode on dnode <dnode_id>;", 0, 0, NULL},
|
||||
{"drop user <user_name>;", 0, 0, NULL},
|
||||
|
@ -136,7 +137,7 @@ SWords shellCommands[] = {
|
|||
{"kill query ", 0, 0, NULL},
|
||||
{"kill transaction ", 0, 0, NULL},
|
||||
#ifdef TD_ENTERPRISE
|
||||
{"merge vgroup <vgroup_id> <vgroup_id>", 0, 0, NULL},
|
||||
{"merge vgroup <vgroup_id> <vgroup_id>;", 0, 0, NULL},
|
||||
#endif
|
||||
{"pause stream <stream_name>;", 0, 0, NULL},
|
||||
#ifdef TD_ENTERPRISE
|
||||
|
@ -163,6 +164,7 @@ SWords shellCommands[] = {
|
|||
{"select timezone();", 0, 0, NULL},
|
||||
{"set max_binary_display_width ", 0, 0, NULL},
|
||||
{"show apps;", 0, 0, NULL},
|
||||
{"show alive;", 0, 0, NULL},
|
||||
{"show create database <db_name> \\G;", 0, 0, NULL},
|
||||
{"show create stable <stb_name> \\G;", 0, 0, NULL},
|
||||
{"show create table <tb_name> \\G;", 0, 0, NULL},
|
||||
|
@ -195,10 +197,9 @@ SWords shellCommands[] = {
|
|||
{"show subscriptions;", 0, 0, NULL},
|
||||
{"show tables;", 0, 0, NULL},
|
||||
{"show tables like", 0, 0, NULL},
|
||||
{"show table distributed <all_table>", 0, 0, NULL},
|
||||
{"show tags from <tb_name>", 0, 0, NULL},
|
||||
{"show tags from <db_name>", 0, 0, NULL},
|
||||
{"show table tags from <all_table>", 0, 0, NULL},
|
||||
{"show table distributed <all_table>;", 0, 0, NULL},
|
||||
{"show tags from <tb_name>;", 0, 0, NULL},
|
||||
{"show table tags from <all_table>;", 0, 0, NULL},
|
||||
{"show topics;", 0, 0, NULL},
|
||||
{"show transactions;", 0, 0, NULL},
|
||||
{"show tsmas;", 0, 0, NULL},
|
||||
|
@ -215,15 +216,15 @@ SWords shellCommands[] = {
|
|||
#ifdef TD_ENTERPRISE
|
||||
{"show views;", 0, 0, NULL},
|
||||
{"show arbgroups;", 0, 0, NULL},
|
||||
{"split vgroup <vgroup_id>", 0, 0, NULL},
|
||||
{"s3migrate database <db_name>", 0, 0, NULL},
|
||||
{"split vgroup <vgroup_id>;", 0, 0, NULL},
|
||||
{"s3migrate database <db_name>;", 0, 0, NULL},
|
||||
#endif
|
||||
{"insert into <tb_name> values(", 0, 0, NULL},
|
||||
{"insert into <tb_name> using <stb_name> tags(", 0, 0, NULL},
|
||||
{"insert into <tb_name> using <stb_name> <anyword> values(", 0, 0, NULL},
|
||||
{"insert into <tb_name> file ", 0, 0, NULL},
|
||||
{"trim database <db_name>", 0, 0, NULL},
|
||||
{"use <db_name>", 0, 0, NULL},
|
||||
{"trim database <db_name>;", 0, 0, NULL},
|
||||
{"use <db_name>;", 0, 0, NULL},
|
||||
{"quit", 0, 0, NULL}};
|
||||
|
||||
// where keyword
|
||||
|
@ -363,6 +364,7 @@ char* field_options[] = {
|
|||
char* global_keys[] = {
|
||||
"tbname",
|
||||
"now",
|
||||
"vgroups",
|
||||
"_wstart",
|
||||
"_wend",
|
||||
"_wduration",
|
||||
|
@ -581,6 +583,7 @@ void showHelp() {
|
|||
select timezone();\n\
|
||||
set max_binary_display_width ...\n\
|
||||
show apps;\n\
|
||||
show alive;\n\
|
||||
show create database <db_name>;\n\
|
||||
show create stable <stb_name>;\n\
|
||||
show create table <tb_name>;\n\
|
||||
|
@ -698,7 +701,12 @@ SWord* addWord(const char* p, int32_t len, bool pattern) {
|
|||
|
||||
// check format
|
||||
if (pattern && len > 0) {
|
||||
if (p[len-1] == ';') {
|
||||
word->type = wordType(p, len - 1);
|
||||
word->end = true;
|
||||
} else {
|
||||
word->type = wordType(p, len);
|
||||
}
|
||||
} else {
|
||||
word->type = WT_TEXT;
|
||||
}
|
||||
|
@ -1305,9 +1313,9 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) {
|
|||
const char* str = NULL;
|
||||
int strLen = 0;
|
||||
|
||||
SWord* word = MATCH_WORD(match);
|
||||
if (firstMatchIndex == curMatchIndex && lastWordBytes == -1) {
|
||||
// first press tab
|
||||
SWord* word = MATCH_WORD(match);
|
||||
str = word->word + match->matchLen;
|
||||
strLen = word->len - match->matchLen;
|
||||
lastMatchIndex = firstMatchIndex;
|
||||
|
@ -1315,8 +1323,6 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) {
|
|||
} else {
|
||||
if (lastWordBytes == -1) return;
|
||||
deleteCount(cmd, lastWordBytes);
|
||||
|
||||
SWord* word = MATCH_WORD(match);
|
||||
str = word->word;
|
||||
strLen = word->len;
|
||||
// set current to last
|
||||
|
@ -1324,9 +1330,18 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) {
|
|||
lastWordBytes = word->len;
|
||||
}
|
||||
|
||||
if (word->end) {
|
||||
// append end ';'
|
||||
char *p = taosMemoryMalloc(strLen + 8);
|
||||
strcpy(p, str);
|
||||
strcat(p, ";");
|
||||
shellInsertStr(cmd, (char *)p, strLen + 1);
|
||||
taosMemoryFree(p);
|
||||
} else {
|
||||
// insert new
|
||||
shellInsertStr(cmd, (char *)str, strLen);
|
||||
}
|
||||
}
|
||||
|
||||
// main key press tab , matched return true else false
|
||||
bool firstMatchCommand(TAOS* con, SShellCmd* cmd) {
|
||||
|
|
Loading…
Reference in New Issue