Merge pull request #19402 from taosdata/chore/sangshuduo/TD-19391-oem-support
chore: prompt support
This commit is contained in:
commit
45ef1c7405
|
@ -1,319 +0,0 @@
|
|||
#!/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) {
|
|||
}
|
||||
}
|
||||
|
||||
dInfo("TDengine initialized successfully");
|
||||
dmReportStartup("TDengine", "initialized successfully");
|
||||
dInfo("The daemon initialized successfully");
|
||||
dmReportStartup("The daemon", "initialized successfully");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ int32_t dmRunDnode(SDnode *pDnode) {
|
|||
|
||||
while (1) {
|
||||
if (pDnode->stop) {
|
||||
dInfo("TDengine is about to stop");
|
||||
dInfo("The daemon is about to stop");
|
||||
dmSetStatus(pDnode, DND_STAT_STOPPED);
|
||||
dmStopNodes(pDnode);
|
||||
dmCloseNodes(pDnode);
|
||||
|
|
|
@ -71,7 +71,7 @@ char *taosCharsetReplace(char *charsetstr) {
|
|||
* seems does not response as expected.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
|
|
@ -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) {
|
||||
#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;
|
||||
#else
|
||||
memset(ucs4, 0, ucs4_max_len);
|
||||
|
@ -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) {
|
||||
#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;
|
||||
#else
|
||||
|
||||
|
@ -263,7 +263,7 @@ int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) {
|
|||
}
|
||||
bool taosValidateEncodec(const char *encodec) {
|
||||
#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;
|
||||
#else
|
||||
iconv_t cd = iconv_open(encodec, DEFAULT_UNICODE_ENCODEC);
|
||||
|
|
|
@ -26,6 +26,10 @@ ELSE ()
|
|||
SET(LINK_WEBSOCKET "")
|
||||
ENDIF ()
|
||||
|
||||
IF (CUS_NAME OR CUS_PROMPT)
|
||||
ADD_DEFINITIONS(-I${CMAKE_CURRENT_SOURCE_DIR}/../../../enterprise/packaging)
|
||||
ENDIF (CUS_NAME)
|
||||
|
||||
if(TD_WINDOWS)
|
||||
target_link_libraries(shell PUBLIC taos_static ${LINK_WEBSOCKET})
|
||||
else()
|
||||
|
|
|
@ -24,13 +24,13 @@ void pressTabKey(SShellCmd* cmd);
|
|||
// press othr key
|
||||
void pressOtherKey(char c);
|
||||
|
||||
// init shell auto funciton , shell start call once
|
||||
// init shell auto function , shell start call once
|
||||
bool shellAutoInit();
|
||||
|
||||
// set conn
|
||||
void shellSetConn(TAOS* conn);
|
||||
|
||||
// exit shell auto funciton, shell exit call once
|
||||
// exit shell auto function, shell exit call once
|
||||
void shellAutoExit();
|
||||
|
||||
// callback autotab module
|
||||
|
|
|
@ -80,8 +80,9 @@ typedef struct {
|
|||
} SShellArgs;
|
||||
|
||||
typedef struct {
|
||||
const char* clientVersion;
|
||||
const char* promptHeader;
|
||||
const char *clientVersion;
|
||||
char cusName[32];
|
||||
char promptHeader[32];
|
||||
const char* promptContinue;
|
||||
const char* osname;
|
||||
int32_t promptSize;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
//
|
||||
// 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'
|
||||
|
||||
// capacity save char is 95
|
||||
|
|
|
@ -19,10 +19,25 @@
|
|||
|
||||
#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 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_USER "The user name to use when connecting to the server."
|
||||
#define SHELL_PASSWORD "The password to use when connecting to the server."
|
||||
|
@ -41,7 +56,6 @@
|
|||
#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_VERSION "Print program version."
|
||||
#define SHELL_EMAIL "<support@taosdata.com>"
|
||||
|
||||
#ifdef WEBSOCKET
|
||||
#define SHELL_DSN "The dsn to use when connecting to cloud server."
|
||||
|
@ -78,7 +92,7 @@ void shellPrintHelp() {
|
|||
#endif
|
||||
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("\r\n\r\nReport bugs to %s.\r\n", SHELL_EMAIL);
|
||||
printf("\r\n\r\nReport bugs to %s.\r\n", cusEmail);
|
||||
}
|
||||
|
||||
#ifdef LINUX
|
||||
|
@ -86,7 +100,7 @@ void shellPrintHelp() {
|
|||
#include <termio.h>
|
||||
|
||||
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[] = {
|
||||
{"host", 'h', "HOST", 0, SHELL_HOST},
|
||||
|
@ -388,12 +402,13 @@ static int32_t shellCheckArgs() {
|
|||
|
||||
int32_t shellParseArgs(int32_t argc, char *argv[]) {
|
||||
shellInitArgs(argc, argv);
|
||||
shell.info.clientVersion =
|
||||
"Welcome to the TDengine Command Line Interface, Client Version:%s\r\n"
|
||||
"Copyright (c) 2022 by TDengine, all rights reserved.\r\n\r\n";
|
||||
shell.info.promptHeader = TAOS_CONSOLE_PROMPT_HEADER;
|
||||
shell.info.clientVersion =
|
||||
"Welcome to the %s Command Line Interface, Client Version:%s\r\n"
|
||||
"Copyright (c) 2022 by %s, all rights reserved.\r\n\r\n";
|
||||
strcpy(shell.info.cusName, cusName);
|
||||
sprintf(shell.info.promptHeader, "%s> ", cusPrompt);
|
||||
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);
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
|
|
|
@ -264,7 +264,7 @@ char* key_tags[] = {"tags("};
|
|||
char* key_select[] = {"select "};
|
||||
|
||||
//
|
||||
// ------- gobal variant define ---------
|
||||
// ------- global variant define ---------
|
||||
//
|
||||
int32_t firstMatchIndex = -1; // first 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
|
|||
// show auto tab introduction
|
||||
void printfIntroduction() {
|
||||
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(" * The full list of shortcut keys is as follows: *\n");
|
||||
printf(" * [ TAB ] ...... complete the current word *\n");
|
||||
|
@ -344,7 +352,7 @@ void printfIntroduction() {
|
|||
}
|
||||
|
||||
void showHelp() {
|
||||
printf("\nThe TDengine CLI supports the following commands:");
|
||||
printf("\nThe %s CLI supports the following commands:", shell.info.cusName);
|
||||
printf(
|
||||
"\n\
|
||||
----- A ----- \n\
|
||||
|
@ -595,7 +603,7 @@ void GenerateVarType(int type, char** p, int count) {
|
|||
// -------------------- shell auto ----------------
|
||||
//
|
||||
|
||||
// init shell auto funciton , shell start call once
|
||||
// init shell auto function , shell start call once
|
||||
bool shellAutoInit() {
|
||||
// command
|
||||
int32_t count = SHELL_COMMAND_COUNT();
|
||||
|
@ -628,7 +636,7 @@ bool shellAutoInit() {
|
|||
// set 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() {
|
||||
// free command
|
||||
int32_t count = SHELL_COMMAND_COUNT();
|
||||
|
@ -645,7 +653,7 @@ void shellAutoExit() {
|
|||
}
|
||||
}
|
||||
taosThreadMutexUnlock(&tiresMutex);
|
||||
// destory
|
||||
// destroy
|
||||
taosThreadMutexDestroy(&tiresMutex);
|
||||
|
||||
// free threads
|
||||
|
@ -666,7 +674,7 @@ void shellAutoExit() {
|
|||
//
|
||||
// ------------------- auto ptr for tires --------------------------
|
||||
//
|
||||
bool setNewAuotPtr(int type, STire* pNew) {
|
||||
bool setNewAutoPtr(int type, STire* pNew) {
|
||||
if (pNew == NULL) return false;
|
||||
|
||||
taosThreadMutexLock(&tiresMutex);
|
||||
|
@ -709,7 +717,7 @@ void putBackAutoPtr(int type, STire* tire) {
|
|||
if (tires[type] != tire) {
|
||||
// update by out, can't put back , so free
|
||||
if (--tire->ref == 1) {
|
||||
// support multi thread getAuotPtr
|
||||
// support multi thread getAutoPtr
|
||||
freeTire(tire);
|
||||
}
|
||||
|
||||
|
@ -767,7 +775,7 @@ int writeVarNames(int type, TAOS_RES* tres) {
|
|||
} while (row != NULL);
|
||||
|
||||
// replace old tire
|
||||
setNewAuotPtr(type, tire);
|
||||
setNewAutoPtr(type, tire);
|
||||
|
||||
return numOfRows;
|
||||
}
|
||||
|
@ -1035,7 +1043,7 @@ SWords* matchCommand(SWords* input, bool continueSearch) {
|
|||
for (int32_t i = 0; i < count; i++) {
|
||||
SWords* shellCommand = shellCommands + i;
|
||||
if (continueSearch && lastMatchIndex != -1 && i <= lastMatchIndex) {
|
||||
// new match must greate than lastMatchIndex
|
||||
// new match must greater than lastMatchIndex
|
||||
if (varMode && i == lastMatchIndex) {
|
||||
// do nothing, var match on lastMatchIndex
|
||||
} else {
|
||||
|
@ -1164,7 +1172,7 @@ void createInputFromFirst(SWords* input, SWords* firstMatch) {
|
|||
for (int i = 0; i < firstMatch->matchIndex && word; i++) {
|
||||
// combine source from each word
|
||||
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
|
||||
// move next
|
||||
word = word->next;
|
||||
|
@ -1393,7 +1401,7 @@ bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* sql, int32_t len) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// fill funciton
|
||||
// fill function
|
||||
if (fieldEnd) {
|
||||
// fields is end , need match keyword
|
||||
ret = fillWithType(con, cmd, last, WT_VAR_KEYWORD);
|
||||
|
@ -1576,7 +1584,7 @@ bool matchCreateTable(TAOS* con, SShellCmd* cmd) {
|
|||
|
||||
// tb options
|
||||
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
|
||||
if (p1) {
|
||||
if (strchr(p1 + 1, ')')) { // second ')' end
|
||||
|
|
|
@ -1072,7 +1072,8 @@ void *shellThreadLoop(void *arg) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
SShellArgs *pArgs = &shell.args;
|
||||
|
@ -1127,7 +1128,7 @@ int32_t shellExecute() {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,19 +50,19 @@ bool shellRegexMatch(const char *s, const char *reg, int32_t cflags) {
|
|||
|
||||
int32_t shellCheckIntSize() {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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 0;
|
||||
|
@ -80,7 +80,7 @@ void shellGenerateAuth() {
|
|||
void shellDumpConfig() {
|
||||
SConfig *pCfg = taosGetCfg();
|
||||
if (pCfg == NULL) {
|
||||
printf("TDengine read global config failed!\r\n");
|
||||
printf("read global config failed!\r\n");
|
||||
} else {
|
||||
cfgDumpCfg(pCfg, 1, true);
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ void shellRunSingleCommandWebsocketImp(char *command) {
|
|||
if (reconnectNum == 0) {
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "TDengine server is disconnected, will try to reconnect\n");
|
||||
fprintf(stderr, "The server is disconnected, will try to reconnect\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue