TDengine/tools/shell/src/shellMain.c

80 lines
1.6 KiB
C
Raw Normal View History

2019-07-11 08:36:16 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __USE_XOPEN
2022-04-21 13:09:43 +00:00
#include "shellInt.h"
2022-09-07 02:16:00 +00:00
#include "shellAuto.h"
2022-04-21 13:09:43 +00:00
SShellObj shell = {0};
2022-04-21 13:09:43 +00:00
int main(int argc, char *argv[]) {
shell.exit = false;
#ifdef WEBSOCKET
shell.args.timeout = 10;
shell.args.cloud = true;
#endif
2022-04-21 13:09:43 +00:00
if (shellCheckIntSize() != 0) {
2022-04-21 13:11:02 +00:00
return -1;
2019-07-11 08:36:16 +00:00
}
2022-04-21 13:09:43 +00:00
if (shellParseArgs(argc, argv) != 0) {
2022-04-21 13:11:02 +00:00
return -1;
2019-07-11 08:36:16 +00:00
}
2022-04-21 13:09:43 +00:00
if (shell.args.is_version) {
shellPrintVersion();
2019-07-11 08:36:16 +00:00
return 0;
}
2022-04-21 13:09:43 +00:00
if (shell.args.is_gen_auth) {
shellGenerateAuth();
return 0;
2019-07-11 08:36:16 +00:00
}
2022-04-21 13:09:43 +00:00
if (shell.args.is_help) {
2022-04-22 09:59:41 +00:00
shellPrintHelp();
2022-04-21 13:09:43 +00:00
return 0;
}
#ifdef WEBSOCKET
shellCheckConnectMode();
#endif
2022-04-27 03:27:27 +00:00
taos_init();
2022-04-21 13:09:43 +00:00
if (shell.args.is_dump_config) {
shellDumpConfig();
taos_cleanup();
return 0;
2019-07-11 08:36:16 +00:00
}
2022-04-21 13:09:43 +00:00
if (shell.args.is_startup || shell.args.is_check) {
shellCheckServerStatus();
taos_cleanup();
return 0;
2020-12-17 05:06:20 +00:00
}
if (shell.args.netrole != NULL) {
2022-04-21 13:09:43 +00:00
shellTestNetWork();
taos_cleanup();
return 0;
2019-07-11 08:36:16 +00:00
}
2022-04-19 08:50:25 +00:00
2022-09-07 02:16:00 +00:00
// support port feature
shellAutoInit();
int32_t ret = shellExecute();
shellAutoExit();
return ret;
2022-04-19 08:50:25 +00:00
}