diff --git a/tools/shell/inc/shellAuto.h b/tools/shell/inc/shellAuto.h index 6a317fe5c9..bcf500fefc 100644 --- a/tools/shell/inc/shellAuto.h +++ b/tools/shell/inc/shellAuto.h @@ -39,7 +39,10 @@ void shellAutoExit(); void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb); // introduction -void printfIntroduction(); +void printfIntroduction(bool community); + +// show enterprise AD at start or end +void showAD(bool end); // show all commands help void showHelp(); diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 847bbcf4be..f39fbfbdf5 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -400,27 +400,41 @@ SMatch* lastMatch = NULL; // save last match result int cntDel = 0; // delete byte count after next press tab // show auto tab introduction -void printfIntroduction() { - printf(" ******************************** Tab Completion ************************************\n"); +void printfIntroduction(bool community) { + printf(" ********************************* Tab Completion *************************************\n"); char secondLine[160] = "\0"; sprintf(secondLine, " * The %s CLI supports tab completion for a variety of items, ", shell.info.cusName); printf("%s", secondLine); int secondLineLen = strlen(secondLine); - while (87 - (secondLineLen++) > 0) { + while (89 - (secondLineLen++) > 0) { printf(" "); } printf("*\n"); - printf(" * including database names, table names, function names and keywords. *\n"); - printf(" * The full list of shortcut keys is as follows: *\n"); - printf(" * [ TAB ] ...... complete the current word *\n"); - printf(" * ...... if used on a blank line, display all supported commands *\n"); - printf(" * [ Ctrl + A ] ...... move cursor to the st[A]rt of the line *\n"); - printf(" * [ Ctrl + E ] ...... move cursor to the [E]nd of the line *\n"); - printf(" * [ Ctrl + W ] ...... move cursor to the middle of the line *\n"); - printf(" * [ Ctrl + L ] ...... clear the entire screen *\n"); - printf(" * [ Ctrl + K ] ...... clear the screen after the cursor *\n"); - printf(" * [ Ctrl + U ] ...... clear the screen before the cursor *\n"); - printf(" **************************************************************************************\n\n"); + printf(" * including database names, table names, function names and keywords. *\n"); + printf(" * The full list of shortcut keys is as follows: *\n"); + printf(" * [ TAB ] ...... complete the current word *\n"); + printf(" * ...... if used on a blank line, display all supported commands *\n"); + printf(" * [ Ctrl + A ] ...... move cursor to the st[A]rt of the line *\n"); + printf(" * [ Ctrl + E ] ...... move cursor to the [E]nd of the line *\n"); + printf(" * [ Ctrl + W ] ...... move cursor to the middle of the line *\n"); + printf(" * [ Ctrl + L ] ...... clear the entire screen *\n"); + printf(" * [ Ctrl + K ] ...... clear the screen after the cursor *\n"); + printf(" * [ Ctrl + U ] ...... clear the screen before the cursor *\n"); + if(community) { + printf(" * ------------------------------------------------------------------------------------ *\n"); + printf(" * You are using TDengine OSS. To experience advanced features, like backup/restore, *\n"); + printf(" * privilege control and more, or receive 7x24 technical support, try TDengine *\n"); + printf(" * Enterprise or Free Cloud Trial. Learn more at https://tdengine.com *\n"); + } + printf(" ****************************************************************************************\n\n"); +} + +// show enterprise AD +void showAD(bool end) { + printf(" You are using TDengine OSS. To experience advanced features, like backup/restore, \n"); + printf(" privilege control and more, or receive 7x24 technical support, try TDengine Enterprise \n"); + printf(" or Free Cloud Trial. Learn more at https://tdengine.com \n"); + printf(" \n"); } void showHelp() { diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 995d3d04ec..5c71396ea9 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -56,7 +56,7 @@ static void shellWriteHistory(); static void shellPrintError(TAOS_RES *tres, int64_t st); static bool shellIsCommentLine(char *line); static void shellSourceFile(const char *file); -static void shellGetGrantInfo(); +static bool shellGetGrantInfo(); static void shellCleanup(void *arg); static void *shellCancelHandler(void *arg); @@ -1150,7 +1150,8 @@ void shellSourceFile(const char *file) { taosCloseFile(&pFile); } -void shellGetGrantInfo() { +bool shellGetGrantInfo(char* buf) { + bool community = true; char sinfo[1024] = {0}; tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo)); strtok(sinfo, "\r\n"); @@ -1165,7 +1166,7 @@ void shellGetGrantInfo() { code != TSDB_CODE_PAR_PERMISSION_DENIED) { fprintf(stderr, "Failed to check Server Edition, Reason:0x%04x:%s\r\n\r\n", code, taos_errstr(tres)); } - return; + return community; } int32_t num_fields = taos_field_count(tres); @@ -1194,11 +1195,13 @@ void shellGetGrantInfo() { memcpy(expired, row[2], fields[2].bytes); if (strcmp(serverVersion, "community") == 0) { - fprintf(stdout, "Server is Community Edition.\r\n"); + community = true; } else if (strcmp(expiretime, "unlimited") == 0) { - fprintf(stdout, "Server is Enterprise %s Edition, %s and will never expire.\r\n", serverVersion, sinfo); + community = false; + sprintf(buf, "Server is Enterprise %s Edition, %s and will never expire.\r\n", serverVersion, sinfo); } else { - fprintf(stdout, "Server is Enterprise %s Edition, %s and will expire at %s.\r\n", serverVersion, sinfo, + community = false; + sprintf(buf, "Server is Enterprise %s Edition, %s and will expire at %s.\r\n", serverVersion, sinfo, expiretime); } @@ -1206,6 +1209,7 @@ void shellGetGrantInfo() { } fprintf(stdout, "\r\n"); + return community; } #ifdef WINDOWS @@ -1364,10 +1368,22 @@ int32_t shellExecute() { #ifdef WEBSOCKET if (!shell.args.restful && !shell.args.cloud) { #endif +char buf[512] = ""; +bool community = shellGetGrantInfo(buf); #ifndef WINDOWS - printfIntroduction(); + printfIntroduction(community); +#else +#ifndef WEBSOCKET + if(community) { + showAD(false); + } +#endif #endif - shellGetGrantInfo(); +// printf version +if(!community) { + printf("%s\n", buf); +} + #ifdef WEBSOCKET } #endif @@ -1380,6 +1396,13 @@ int32_t shellExecute() { break; } } +#ifndef WEBSOCKET + // commnuity + if (community) { + showAD(true); + } +#endif + taosThreadJoin(spid, NULL); shellCleanupHistory();