提交 3a0a720e 编写于 作者: sangshuduo's avatar sangshuduo

[TD-5844]<feature>: make cmd line parameter similar.

上级 39280a5e
...@@ -77,7 +77,7 @@ extern char configDir[]; ...@@ -77,7 +77,7 @@ extern char configDir[];
#define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS) #define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS)
#define MAX_USERNAME_SIZE 64 #define MAX_USERNAME_SIZE 64
#define MAX_PASSWORD_SIZE 64 #define MAX_PASSWORD_SIZE 16
#define MAX_HOSTNAME_SIZE 253 // https://man7.org/linux/man-pages/man7/hostname.7.html #define MAX_HOSTNAME_SIZE 253 // https://man7.org/linux/man-pages/man7/hostname.7.html
#define MAX_TB_NAME_SIZE 64 #define MAX_TB_NAME_SIZE 64
#define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space #define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space
...@@ -216,7 +216,7 @@ typedef struct SArguments_S { ...@@ -216,7 +216,7 @@ typedef struct SArguments_S {
uint16_t port; uint16_t port;
uint16_t iface; uint16_t iface;
char * user; char * user;
char * password; char password[MAX_PASSWORD_SIZE];
char * database; char * database;
int replica; int replica;
char * tb_prefix; char * tb_prefix;
...@@ -709,24 +709,24 @@ static void printHelp() { ...@@ -709,24 +709,24 @@ static void printHelp() {
printf("%s%s%s%s\n", indent, "-u", indent, printf("%s%s%s%s\n", indent, "-u", indent,
"The TDengine user name to use when connecting to the server. Default is 'root'."); "The TDengine user name to use when connecting to the server. Default is 'root'.");
#ifdef _TD_POWER_ #ifdef _TD_POWER_
printf("%s%s%s%s\n", indent, "-P", indent, printf("%s%s%s%s\n", indent, "-p", indent,
"The password to use when connecting to the server. Default is 'powerdb'."); "The password to use when connecting to the server. Default is 'powerdb'.");
printf("%s%s%s%s\n", indent, "-c", indent, printf("%s%s%s%s\n", indent, "-c", indent,
"Configuration directory. Default is '/etc/power/'."); "Configuration directory. Default is '/etc/power/'.");
#elif (_TD_TQ_ == true) #elif (_TD_TQ_ == true)
printf("%s%s%s%s\n", indent, "-P", indent, printf("%s%s%s%s\n", indent, "-p", indent,
"The password to use when connecting to the server. Default is 'tqueue'."); "The password to use when connecting to the server. Default is 'tqueue'.");
printf("%s%s%s%s\n", indent, "-c", indent, printf("%s%s%s%s\n", indent, "-c", indent,
"Configuration directory. Default is '/etc/tq/'."); "Configuration directory. Default is '/etc/tq/'.");
#else #else
printf("%s%s%s%s\n", indent, "-P", indent, printf("%s%s%s%s\n", indent, "-p", indent,
"The password to use when connecting to the server. Default is 'taosdata'."); "The password to use when connecting to the server. Default is 'taosdata'.");
printf("%s%s%s%s\n", indent, "-c", indent, printf("%s%s%s%s\n", indent, "-c", indent,
"Configuration directory. Default is '/etc/taos/'."); "Configuration directory. Default is '/etc/taos/'.");
#endif #endif
printf("%s%s%s%s\n", indent, "-h", indent, printf("%s%s%s%s\n", indent, "-h", indent,
"The host to connect to TDengine. Default is localhost."); "The host to connect to TDengine. Default is localhost.");
printf("%s%s%s%s\n", indent, "-p", indent, printf("%s%s%s%s\n", indent, "-P", indent,
"The TCP/IP port number to use for the connection. Default is 0."); "The TCP/IP port number to use for the connection. Default is 0.");
printf("%s%s%s%s\n", indent, "-I", indent, printf("%s%s%s%s\n", indent, "-I", indent,
#if STMT_IFACE_ENABLED == 1 #if STMT_IFACE_ENABLED == 1
...@@ -826,11 +826,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -826,11 +826,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->host = argv[++i]; arguments->host = argv[++i];
} else if (strcmp(argv[i], "-p") == 0) { } else if (strcmp(argv[i], "-P") == 0) {
if ((argc == i+1) || if ((argc == i+1) ||
(!isStringNumber(argv[i+1]))) { (!isStringNumber(argv[i+1]))) {
printHelp(); printHelp();
errorPrint("%s", "\n\t-p need a number following!\n"); errorPrint("%s", "\n\t-P need a number following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->port = atoi(argv[++i]); arguments->port = atoi(argv[++i]);
...@@ -860,13 +860,13 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -860,13 +860,13 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->user = argv[++i]; arguments->user = argv[++i];
} else if (strcmp(argv[i], "-P") == 0) { } else if (strncmp(argv[i], "-p", 2) == 0) {
if (argc == i+1) { if (strlen(argv[i]) == 2) {
printHelp(); printf("Enter password:");
errorPrint("%s", "\n\t-P need a valid string following!\n"); scanf("%s", arguments->password);
exit(EXIT_FAILURE); } else {
tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE);
} }
arguments->password = argv[++i];
} else if (strcmp(argv[i], "-o") == 0) { } else if (strcmp(argv[i], "-o") == 0) {
if (argc == i+1) { if (argc == i+1) {
printHelp(); printHelp();
...@@ -1065,7 +1065,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1065,7 +1065,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments->debug_print = true; arguments->debug_print = true;
} else if (strcmp(argv[i], "-gg") == 0) { } else if (strcmp(argv[i], "-gg") == 0) {
arguments->verbose_print = true; arguments->verbose_print = true;
} else if (strcmp(argv[i], "-pp") == 0) { } else if (strcmp(argv[i], "-PP") == 0) {
arguments->performance_print = true; arguments->performance_print = true;
} else if (strcmp(argv[i], "-O") == 0) { } else if (strcmp(argv[i], "-O") == 0) {
if ((argc == i+1) || if ((argc == i+1) ||
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册