未验证 提交 45ef1c74 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #19402 from taosdata/chore/sangshuduo/TD-19391-oem-support

chore: prompt support
#!/bin/bash
#
# Generate the deb package for ubuntu, or rpm package for centos, or tar.gz package for other linux os
set -e
# set -x
# release.sh -v [cluster | edge]
# -c [aarch32 | aarch64 | x64 | x86 | mips64 | loongarch64...]
# -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
# -V [stable | beta]
# -l [full | lite]
# -s [static | dynamic]
# -d [taos | ...]
# -n [2.0.0.3]
# -m [2.0.0.0]
# -H [ false | true]
# set parameters by default value
verMode=edge # [cluster, edge, cloud]
verType=stable # [stable, beta]
cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 loongarch64...]
osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
pagMode=full # [full | lite]
soMode=dynamic # [static | dynamic]
dbName=taos # [taos | ...]
allocator=glibc # [glibc | jemalloc]
verNumber=""
verNumberComp="3.0.0.0"
httpdBuild=false
while getopts "hv:V:c:o:l:s:d:a:n:m:H:" arg; do
case $arg in
v)
#echo "verMode=$OPTARG"
verMode=$(echo $OPTARG)
;;
V)
#echo "verType=$OPTARG"
verType=$(echo $OPTARG)
;;
c)
#echo "cpuType=$OPTARG"
cpuType=$(echo $OPTARG)
;;
l)
#echo "pagMode=$OPTARG"
pagMode=$(echo $OPTARG)
;;
s)
#echo "soMode=$OPTARG"
soMode=$(echo $OPTARG)
;;
d)
#echo "dbName=$OPTARG"
dbName=$(echo $OPTARG)
;;
a)
#echo "allocator=$OPTARG"
allocator=$(echo $OPTARG)
;;
n)
#echo "verNumber=$OPTARG"
verNumber=$(echo $OPTARG)
;;
m)
#echo "verNumberComp=$OPTARG"
verNumberComp=$(echo $OPTARG)
;;
o)
#echo "osType=$OPTARG"
osType=$(echo $OPTARG)
;;
H)
#echo "httpdBuild=$OPTARG"
httpdBuild=$(echo $OPTARG)
;;
h)
echo "Usage: $(basename $0) -v [cluster | edge] "
echo " -c [aarch32 | aarch64 | x64 | x86 | mips64 | loongarch64 ...] "
echo " -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
echo " -V [stable | beta] "
echo " -l [full | lite] "
echo " -a [glibc | jemalloc] "
echo " -s [static | dynamic] "
echo " -d [taos | ...] "
echo " -n [version number] "
echo " -m [compatible version number] "
echo " -H [false | true] "
exit 0
;;
?) #unknow option
echo "unkonw argument"
exit 1
;;
esac
done
osType=$(uname)
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} dbName=${dbName} allocator=${allocator} verNumber=${verNumber} verNumberComp=${verNumberComp} httpdBuild=${httpdBuild}"
curr_dir=$(pwd)
if [ "$osType" == "Darwin" ]; then
script_dir=$(dirname $0)
cd ${script_dir}
script_dir="$(pwd)"
top_dir=${script_dir}/..
else
script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -f ${script_dir}/..)"
fi
csudo=""
#if command -v sudo > /dev/null; then
# csudo="sudo "
#fi
function is_valid_version() {
[ -z $1 ] && return 1 || :
rx='^([0-9]+\.){3}(\*|[0-9]+)$'
if [[ $1 =~ $rx ]]; then
return 0
fi
return 1
}
function vercomp() {
if [[ $1 == $2 ]]; then
echo 0
exit 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i = ${#ver1[@]}; i < ${#ver2[@]}; i++)); do
ver1[i]=0
done
for ((i = 0; i < ${#ver1[@]}; i++)); do
if [[ -z ${ver2[i]} ]]; then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]})); then
echo 1
exit 0
fi
if ((10#${ver1[i]} < 10#${ver2[i]})); then
echo 2
exit 0
fi
done
echo 0
}
# 1. check version information
if ( (! is_valid_version $verNumber) || (! is_valid_version $verNumberComp) || [[ "$(vercomp $verNumber $verNumberComp)" == '2' ]]); then
echo "please enter correct version"
exit 0
fi
echo "=======================new version number: ${verNumber}, compatible version: ${verNumberComp}======================================"
build_time=$(date +"%F %R")
# get commint id from git
gitinfo=$(git rev-parse --verify HEAD)
if [[ "$verMode" == "cluster" ]] || [[ "$verMode" == "cloud" ]]; then
enterprise_dir="${top_dir}/../enterprise"
cd ${enterprise_dir}
gitinfoOfInternal=$(git rev-parse --verify HEAD)
else
gitinfoOfInternal=NULL
fi
cd "${curr_dir}"
# 2. cmake executable file
compile_dir="${top_dir}/debug"
if [ -d ${compile_dir} ]; then
rm -rf ${compile_dir}
fi
mkdir -p ${compile_dir}
cd ${compile_dir}
if [[ "$allocator" == "jemalloc" ]]; then
allocator_macro="-DJEMALLOC_ENABLED=true"
else
allocator_macro=""
fi
if [[ "$dbName" != "taos" ]]; then
source ${enterprise_dir}/packaging/oem/sed_$dbName.sh
replace_community_$dbName
fi
if [[ "$httpdBuild" == "true" ]]; then
BUILD_HTTP=true
else
BUILD_HTTP=false
fi
if [[ "$verMode" == "cluster" ]] || [[ "$verMode" == "cloud" ]]; then
BUILD_HTTP=internal
fi
if [[ "$pagMode" == "full" ]]; then
BUILD_TOOLS=true
else
BUILD_TOOLS=false
fi
# check support cpu type
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]] || [[ "$cpuType" == "loongarch64" ]] ; then
if [ "$verMode" == "edge" ]; then
# community-version compile
cmake ../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
elif [ "$verMode" == "cloud" ]; then
cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DBUILD_TAOSX=true -DBUILD_CLOUD=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
elif [ "$verMode" == "cluster" ]; then
if [[ "$dbName" != "taos" ]]; then
replace_enterprise_$dbName
fi
cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DBUILD_TAOSX=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
fi
else
echo "input cpuType=${cpuType} error!!!"
exit 1
fi
ostype=`uname`
if [ "${ostype}" == "Darwin" ]; then
CORES=$(sysctl -n hw.ncpu)
else
CORES=$(grep -c ^processor /proc/cpuinfo)
fi
if [[ "$allocator" == "jemalloc" ]]; then
# jemalloc need compile first, so disable parallel build
make -j ${CORES} && ${csudo}make install
else
make -j ${CORES} && ${csudo}make install
fi
cd ${curr_dir}
# 3. Call the corresponding script for packaging
if [ "$osType" != "Darwin" ]; then
if [[ "$verMode" != "cluster" ]] && [[ "$verMode" != "cloud" ]] && [[ "$pagMode" == "full" ]] && [[ "$cpuType" == "x64" ]] && [[ "$dbName" == "taos" ]]; then
ret='0'
command -v dpkg >/dev/null 2>&1 || { ret='1'; }
if [ "$ret" -eq 0 ]; then
echo "====do deb package for the ubuntu system===="
output_dir="${top_dir}/debs"
if [ -d ${output_dir} ]; then
rm -rf ${output_dir}
fi
mkdir -p ${output_dir}
cd ${script_dir}/deb
${csudo}./makedeb.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
if [[ "$pagMode" == "full" ]]; then
if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then
cd ${top_dir}/tools/taos-tools/packaging/deb
taos_tools_ver=$(git tag |grep -v taos | sort | tail -1)
[ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
${csudo}./make-taos-tools-deb.sh ${top_dir} \
${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType}
fi
fi
else
echo "==========dpkg command not exist, so not release deb package!!!"
fi
ret='0'
command -v rpmbuild >/dev/null 2>&1 || { ret='1'; }
if [ "$ret" -eq 0 ]; then
echo "====do rpm package for the centos system===="
output_dir="${top_dir}/rpms"
if [ -d ${output_dir} ]; then
rm -rf ${output_dir}
fi
mkdir -p ${output_dir}
cd ${script_dir}/rpm
${csudo}./makerpm.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
if [[ "$pagMode" == "full" ]]; then
if [ -d ${top_dir}/tools/taos-tools/packaging/rpm ]; then
cd ${top_dir}/tools/taos-tools/packaging/rpm
taos_tools_ver=$(git tag |grep -v taos | sort | tail -1)
[ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
${csudo}./make-taos-tools-rpm.sh ${top_dir} \
${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType}
fi
fi
else
echo "==========rpmbuild command not exist, so not release rpm package!!!"
fi
fi
echo "====do tar.gz package for all systems===="
cd ${script_dir}/tools
${csudo}./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp} ${dbName}
${csudo}./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
else
cd ${script_dir}/tools
./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp} ${dbName}
./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
fi
...@@ -109,8 +109,8 @@ static int32_t dmStartNodes(SDnode *pDnode) { ...@@ -109,8 +109,8 @@ static int32_t dmStartNodes(SDnode *pDnode) {
} }
} }
dInfo("TDengine initialized successfully"); dInfo("The daemon initialized successfully");
dmReportStartup("TDengine", "initialized successfully"); dmReportStartup("The daemon", "initialized successfully");
return 0; return 0;
} }
...@@ -142,7 +142,7 @@ int32_t dmRunDnode(SDnode *pDnode) { ...@@ -142,7 +142,7 @@ int32_t dmRunDnode(SDnode *pDnode) {
while (1) { while (1) {
if (pDnode->stop) { if (pDnode->stop) {
dInfo("TDengine is about to stop"); dInfo("The daemon is about to stop");
dmSetStatus(pDnode, DND_STAT_STOPPED); dmSetStatus(pDnode, DND_STAT_STOPPED);
dmStopNodes(pDnode); dmStopNodes(pDnode);
dmCloseNodes(pDnode); dmCloseNodes(pDnode);
......
...@@ -71,7 +71,7 @@ char *taosCharsetReplace(char *charsetstr) { ...@@ -71,7 +71,7 @@ char *taosCharsetReplace(char *charsetstr) {
* seems does not response as expected. * seems does not response as expected.
* *
* In some Linux systems, setLocale(LC_CTYPE, "") may return NULL, in which case the launch of * In some Linux systems, setLocale(LC_CTYPE, "") may return NULL, in which case the launch of
* both the TDengine Server and the Client may be interrupted. * both the Server and the Client may be interrupted.
* *
* In case that the setLocale failed to be executed, the right charset needs to be set. * In case that the setLocale failed to be executed, the right charset needs to be set.
*/ */
......
...@@ -217,7 +217,7 @@ void taosReleaseConv(int32_t idx, iconv_t conv, ConvType type) { ...@@ -217,7 +217,7 @@ void taosReleaseConv(int32_t idx, iconv_t conv, ConvType type) {
bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len) { bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len) {
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV #ifdef DISALLOW_NCHAR_WITHOUT_ICONV
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n"); printf("Nchar cannot be read and written without iconv, please install iconv library and recompile.\n");
return -1; return -1;
#else #else
memset(ucs4, 0, ucs4_max_len); memset(ucs4, 0, ucs4_max_len);
...@@ -245,7 +245,7 @@ bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4 ...@@ -245,7 +245,7 @@ bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) { int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) {
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV #ifdef DISALLOW_NCHAR_WITHOUT_ICONV
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n"); printf("Nchar cannot be read and written without iconv, please install iconv library and recompile.\n");
return -1; return -1;
#else #else
...@@ -263,7 +263,7 @@ int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) { ...@@ -263,7 +263,7 @@ int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) {
} }
bool taosValidateEncodec(const char *encodec) { bool taosValidateEncodec(const char *encodec) {
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV #ifdef DISALLOW_NCHAR_WITHOUT_ICONV
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n"); printf("Nchar cannot be read and written without iconv, please install iconv library and recompile.\n");
return true; return true;
#else #else
iconv_t cd = iconv_open(encodec, DEFAULT_UNICODE_ENCODEC); iconv_t cd = iconv_open(encodec, DEFAULT_UNICODE_ENCODEC);
......
...@@ -26,6 +26,10 @@ ELSE () ...@@ -26,6 +26,10 @@ ELSE ()
SET(LINK_WEBSOCKET "") SET(LINK_WEBSOCKET "")
ENDIF () ENDIF ()
IF (CUS_NAME OR CUS_PROMPT)
ADD_DEFINITIONS(-I${CMAKE_CURRENT_SOURCE_DIR}/../../../enterprise/packaging)
ENDIF (CUS_NAME)
if(TD_WINDOWS) if(TD_WINDOWS)
target_link_libraries(shell PUBLIC taos_static ${LINK_WEBSOCKET}) target_link_libraries(shell PUBLIC taos_static ${LINK_WEBSOCKET})
else() else()
......
...@@ -24,13 +24,13 @@ void pressTabKey(SShellCmd* cmd); ...@@ -24,13 +24,13 @@ void pressTabKey(SShellCmd* cmd);
// press othr key // press othr key
void pressOtherKey(char c); void pressOtherKey(char c);
// init shell auto funciton , shell start call once // init shell auto function , shell start call once
bool shellAutoInit(); bool shellAutoInit();
// set conn // set conn
void shellSetConn(TAOS* conn); void shellSetConn(TAOS* conn);
// exit shell auto funciton, shell exit call once // exit shell auto function, shell exit call once
void shellAutoExit(); void shellAutoExit();
// callback autotab module // callback autotab module
......
...@@ -80,8 +80,9 @@ typedef struct { ...@@ -80,8 +80,9 @@ typedef struct {
} SShellArgs; } SShellArgs;
typedef struct { typedef struct {
const char* clientVersion; const char *clientVersion;
const char* promptHeader; char cusName[32];
char promptHeader[32];
const char* promptContinue; const char* promptContinue;
const char* osname; const char* osname;
int32_t promptSize; int32_t promptSize;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
// //
// The prefix search tree is a efficient storage words and search words tree, it support 95 visible ascii code character // The prefix search tree is a efficient storage words and search words tree, it support 95 visible ascii code character
// //
#define FIRST_ASCII 40 // first visiable char is '0' #define FIRST_ASCII 40 // first visible char is '0'
#define LAST_ASCII 122 // last visilbe char is 'z' #define LAST_ASCII 122 // last visilbe char is 'z'
// capacity save char is 95 // capacity save char is 95
......
...@@ -19,10 +19,25 @@ ...@@ -19,10 +19,25 @@
#include "shellInt.h" #include "shellInt.h"
#define TAOS_CONSOLE_PROMPT_HEADER "taos> " #ifndef CUS_NAME
char cusName[] = "TDengine";
#endif
#ifndef CUS_PROMPT
char cusPrompt[] = "taos";
#endif
#ifndef CUS_EMAIL
char cusEmail[] = "<support@taosdata.com>";
#endif
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
#include "cus_name.h"
#endif
#define TAOS_CONSOLE_PROMPT_CONTINUE " -> " #define TAOS_CONSOLE_PROMPT_CONTINUE " -> "
#define SHELL_HOST "TDengine server FQDN to connect. The default host is localhost." #define SHELL_HOST "The server FQDN to connect. The default host is localhost."
#define SHELL_PORT "The TCP/IP port number to use for the connection." #define SHELL_PORT "The TCP/IP port number to use for the connection."
#define SHELL_USER "The user name to use when connecting to the server." #define SHELL_USER "The user name to use when connecting to the server."
#define SHELL_PASSWORD "The password to use when connecting to the server." #define SHELL_PASSWORD "The password to use when connecting to the server."
...@@ -41,7 +56,6 @@ ...@@ -41,7 +56,6 @@
#define SHELL_PKT_LEN "Packet length used for net test, default is 1024 bytes." #define SHELL_PKT_LEN "Packet length used for net test, default is 1024 bytes."
#define SHELL_PKT_NUM "Packet numbers used for net test, default is 100." #define SHELL_PKT_NUM "Packet numbers used for net test, default is 100."
#define SHELL_VERSION "Print program version." #define SHELL_VERSION "Print program version."
#define SHELL_EMAIL "<support@taosdata.com>"
#ifdef WEBSOCKET #ifdef WEBSOCKET
#define SHELL_DSN "The dsn to use when connecting to cloud server." #define SHELL_DSN "The dsn to use when connecting to cloud server."
...@@ -78,7 +92,7 @@ void shellPrintHelp() { ...@@ -78,7 +92,7 @@ void shellPrintHelp() {
#endif #endif
printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH); printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH);
printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION); printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION);
printf("\r\n\r\nReport bugs to %s.\r\n", SHELL_EMAIL); printf("\r\n\r\nReport bugs to %s.\r\n", cusEmail);
} }
#ifdef LINUX #ifdef LINUX
...@@ -86,7 +100,7 @@ void shellPrintHelp() { ...@@ -86,7 +100,7 @@ void shellPrintHelp() {
#include <termio.h> #include <termio.h>
const char *argp_program_version = version; const char *argp_program_version = version;
const char *argp_program_bug_address = SHELL_EMAIL; const char *argp_program_bug_address = cusEmail;
static struct argp_option shellOptions[] = { static struct argp_option shellOptions[] = {
{"host", 'h', "HOST", 0, SHELL_HOST}, {"host", 'h', "HOST", 0, SHELL_HOST},
...@@ -388,12 +402,13 @@ static int32_t shellCheckArgs() { ...@@ -388,12 +402,13 @@ static int32_t shellCheckArgs() {
int32_t shellParseArgs(int32_t argc, char *argv[]) { int32_t shellParseArgs(int32_t argc, char *argv[]) {
shellInitArgs(argc, argv); shellInitArgs(argc, argv);
shell.info.clientVersion = shell.info.clientVersion =
"Welcome to the TDengine Command Line Interface, Client Version:%s\r\n" "Welcome to the %s Command Line Interface, Client Version:%s\r\n"
"Copyright (c) 2022 by TDengine, all rights reserved.\r\n\r\n"; "Copyright (c) 2022 by %s, all rights reserved.\r\n\r\n";
shell.info.promptHeader = TAOS_CONSOLE_PROMPT_HEADER; strcpy(shell.info.cusName, cusName);
sprintf(shell.info.promptHeader, "%s> ", cusPrompt);
shell.info.promptContinue = TAOS_CONSOLE_PROMPT_CONTINUE; shell.info.promptContinue = TAOS_CONSOLE_PROMPT_CONTINUE;
shell.info.promptSize = 6; shell.info.promptSize = strlen(shell.info.promptHeader);
snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), "version: %s", version); snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), "version: %s", version);
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
......
...@@ -264,7 +264,7 @@ char* key_tags[] = {"tags("}; ...@@ -264,7 +264,7 @@ char* key_tags[] = {"tags("};
char* key_select[] = {"select "}; char* key_select[] = {"select "};
// //
// ------- gobal variant define --------- // ------- global variant define ---------
// //
int32_t firstMatchIndex = -1; // first match shellCommands index int32_t firstMatchIndex = -1; // first match shellCommands index
int32_t lastMatchIndex = -1; // last match shellCommands index int32_t lastMatchIndex = -1; // last match shellCommands index
...@@ -329,7 +329,15 @@ int cntDel = 0; // delete byte count after next press tab ...@@ -329,7 +329,15 @@ int cntDel = 0; // delete byte count after next press tab
// show auto tab introduction // show auto tab introduction
void printfIntroduction() { void printfIntroduction() {
printf(" ****************************** Tab Completion **********************************\n"); printf(" ****************************** Tab Completion **********************************\n");
printf(" * The TDengine CLI supports tab completion for a variety of items, *\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 (84-(secondLineLen++) > 0) {
printf(" ");
}
printf("*\n");
printf(" * including database names, table names, function names and keywords. *\n"); printf(" * including database names, table names, function names and keywords. *\n");
printf(" * The full list of shortcut keys is as follows: *\n"); printf(" * The full list of shortcut keys is as follows: *\n");
printf(" * [ TAB ] ...... complete the current word *\n"); printf(" * [ TAB ] ...... complete the current word *\n");
...@@ -344,7 +352,7 @@ void printfIntroduction() { ...@@ -344,7 +352,7 @@ void printfIntroduction() {
} }
void showHelp() { void showHelp() {
printf("\nThe TDengine CLI supports the following commands:"); printf("\nThe %s CLI supports the following commands:", shell.info.cusName);
printf( printf(
"\n\ "\n\
----- A ----- \n\ ----- A ----- \n\
...@@ -595,7 +603,7 @@ void GenerateVarType(int type, char** p, int count) { ...@@ -595,7 +603,7 @@ void GenerateVarType(int type, char** p, int count) {
// -------------------- shell auto ---------------- // -------------------- shell auto ----------------
// //
// init shell auto funciton , shell start call once // init shell auto function , shell start call once
bool shellAutoInit() { bool shellAutoInit() {
// command // command
int32_t count = SHELL_COMMAND_COUNT(); int32_t count = SHELL_COMMAND_COUNT();
...@@ -628,7 +636,7 @@ bool shellAutoInit() { ...@@ -628,7 +636,7 @@ bool shellAutoInit() {
// set conn // set conn
void shellSetConn(TAOS* conn) { varCon = conn; } void shellSetConn(TAOS* conn) { varCon = conn; }
// exit shell auto funciton, shell exit call once // exit shell auto function, shell exit call once
void shellAutoExit() { void shellAutoExit() {
// free command // free command
int32_t count = SHELL_COMMAND_COUNT(); int32_t count = SHELL_COMMAND_COUNT();
...@@ -645,7 +653,7 @@ void shellAutoExit() { ...@@ -645,7 +653,7 @@ void shellAutoExit() {
} }
} }
taosThreadMutexUnlock(&tiresMutex); taosThreadMutexUnlock(&tiresMutex);
// destory // destroy
taosThreadMutexDestroy(&tiresMutex); taosThreadMutexDestroy(&tiresMutex);
// free threads // free threads
...@@ -666,7 +674,7 @@ void shellAutoExit() { ...@@ -666,7 +674,7 @@ void shellAutoExit() {
// //
// ------------------- auto ptr for tires -------------------------- // ------------------- auto ptr for tires --------------------------
// //
bool setNewAuotPtr(int type, STire* pNew) { bool setNewAutoPtr(int type, STire* pNew) {
if (pNew == NULL) return false; if (pNew == NULL) return false;
taosThreadMutexLock(&tiresMutex); taosThreadMutexLock(&tiresMutex);
...@@ -709,7 +717,7 @@ void putBackAutoPtr(int type, STire* tire) { ...@@ -709,7 +717,7 @@ void putBackAutoPtr(int type, STire* tire) {
if (tires[type] != tire) { if (tires[type] != tire) {
// update by out, can't put back , so free // update by out, can't put back , so free
if (--tire->ref == 1) { if (--tire->ref == 1) {
// support multi thread getAuotPtr // support multi thread getAutoPtr
freeTire(tire); freeTire(tire);
} }
...@@ -767,7 +775,7 @@ int writeVarNames(int type, TAOS_RES* tres) { ...@@ -767,7 +775,7 @@ int writeVarNames(int type, TAOS_RES* tres) {
} while (row != NULL); } while (row != NULL);
// replace old tire // replace old tire
setNewAuotPtr(type, tire); setNewAutoPtr(type, tire);
return numOfRows; return numOfRows;
} }
...@@ -1035,7 +1043,7 @@ SWords* matchCommand(SWords* input, bool continueSearch) { ...@@ -1035,7 +1043,7 @@ SWords* matchCommand(SWords* input, bool continueSearch) {
for (int32_t i = 0; i < count; i++) { for (int32_t i = 0; i < count; i++) {
SWords* shellCommand = shellCommands + i; SWords* shellCommand = shellCommands + i;
if (continueSearch && lastMatchIndex != -1 && i <= lastMatchIndex) { if (continueSearch && lastMatchIndex != -1 && i <= lastMatchIndex) {
// new match must greate than lastMatchIndex // new match must greater than lastMatchIndex
if (varMode && i == lastMatchIndex) { if (varMode && i == lastMatchIndex) {
// do nothing, var match on lastMatchIndex // do nothing, var match on lastMatchIndex
} else { } else {
...@@ -1164,7 +1172,7 @@ void createInputFromFirst(SWords* input, SWords* firstMatch) { ...@@ -1164,7 +1172,7 @@ void createInputFromFirst(SWords* input, SWords* firstMatch) {
for (int i = 0; i < firstMatch->matchIndex && word; i++) { for (int i = 0; i < firstMatch->matchIndex && word; i++) {
// combine source from each word // combine source from each word
strncpy(input->source + input->source_len, word->word, word->len); strncpy(input->source + input->source_len, word->word, word->len);
strcat(input->source, " "); // append blank splite strcat(input->source, " "); // append blank space
input->source_len += word->len + 1; // 1 is blank length input->source_len += word->len + 1; // 1 is blank length
// move next // move next
word = word->next; word = word->next;
...@@ -1393,7 +1401,7 @@ bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* sql, int32_t len) { ...@@ -1393,7 +1401,7 @@ bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* sql, int32_t len) {
return true; return true;
} }
// fill funciton // fill function
if (fieldEnd) { if (fieldEnd) {
// fields is end , need match keyword // fields is end , need match keyword
ret = fillWithType(con, cmd, last, WT_VAR_KEYWORD); ret = fillWithType(con, cmd, last, WT_VAR_KEYWORD);
...@@ -1576,7 +1584,7 @@ bool matchCreateTable(TAOS* con, SShellCmd* cmd) { ...@@ -1576,7 +1584,7 @@ bool matchCreateTable(TAOS* con, SShellCmd* cmd) {
// tb options // tb options
if (!ret) { if (!ret) {
// find like create talbe st (...) tags(..) <here is fill tb option area> // find like create table st (...) tags(..) <here is fill tb option area>
char* p1 = strchr(ps, ')'); // first ')' end char* p1 = strchr(ps, ')'); // first ')' end
if (p1) { if (p1) {
if (strchr(p1 + 1, ')')) { // second ')' end if (strchr(p1 + 1, ')')) { // second ')' end
......
...@@ -1072,7 +1072,8 @@ void *shellThreadLoop(void *arg) { ...@@ -1072,7 +1072,8 @@ void *shellThreadLoop(void *arg) {
} }
int32_t shellExecute() { int32_t shellExecute() {
printf(shell.info.clientVersion, taos_get_client_info()); printf(shell.info.clientVersion, shell.info.cusName,
taos_get_client_info(), shell.info.cusName);
fflush(stdout); fflush(stdout);
SShellArgs *pArgs = &shell.args; SShellArgs *pArgs = &shell.args;
...@@ -1127,7 +1128,7 @@ int32_t shellExecute() { ...@@ -1127,7 +1128,7 @@ int32_t shellExecute() {
} }
if (tsem_init(&shell.cancelSem, 0, 0) != 0) { if (tsem_init(&shell.cancelSem, 0, 0) != 0) {
printf("failed to create cancel semphore\r\n"); printf("failed to create cancel semaphore\r\n");
return -1; return -1;
} }
......
...@@ -50,19 +50,19 @@ bool shellRegexMatch(const char *s, const char *reg, int32_t cflags) { ...@@ -50,19 +50,19 @@ bool shellRegexMatch(const char *s, const char *reg, int32_t cflags) {
int32_t shellCheckIntSize() { int32_t shellCheckIntSize() {
if (sizeof(int8_t) != 1) { if (sizeof(int8_t) != 1) {
printf("taos int8 size is %d(!= 1)", (int)sizeof(int8_t)); printf("int8 size is %d(!= 1)", (int)sizeof(int8_t));
return -1; return -1;
} }
if (sizeof(int16_t) != 2) { if (sizeof(int16_t) != 2) {
printf("taos int16 size is %d(!= 2)", (int)sizeof(int16_t)); printf("int16 size is %d(!= 2)", (int)sizeof(int16_t));
return -1; return -1;
} }
if (sizeof(int32_t) != 4) { if (sizeof(int32_t) != 4) {
printf("taos int32 size is %d(!= 4)", (int)sizeof(int32_t)); printf("int32 size is %d(!= 4)", (int)sizeof(int32_t));
return -1; return -1;
} }
if (sizeof(int64_t) != 8) { if (sizeof(int64_t) != 8) {
printf("taos int64 size is %d(!= 8)", (int)sizeof(int64_t)); printf("int64 size is %d(!= 8)", (int)sizeof(int64_t));
return -1; return -1;
} }
return 0; return 0;
...@@ -80,7 +80,7 @@ void shellGenerateAuth() { ...@@ -80,7 +80,7 @@ void shellGenerateAuth() {
void shellDumpConfig() { void shellDumpConfig() {
SConfig *pCfg = taosGetCfg(); SConfig *pCfg = taosGetCfg();
if (pCfg == NULL) { if (pCfg == NULL) {
printf("TDengine read global config failed!\r\n"); printf("read global config failed!\r\n");
} else { } else {
cfgDumpCfg(pCfg, 1, true); cfgDumpCfg(pCfg, 1, true);
} }
......
...@@ -235,7 +235,7 @@ void shellRunSingleCommandWebsocketImp(char *command) { ...@@ -235,7 +235,7 @@ void shellRunSingleCommandWebsocketImp(char *command) {
if (reconnectNum == 0) { if (reconnectNum == 0) {
continue; continue;
} else { } else {
fprintf(stderr, "TDengine server is disconnected, will try to reconnect\n"); fprintf(stderr, "The server is disconnected, will try to reconnect\n");
} }
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册