Merge pull request #11864 from taosdata/feature/ZhiqiangWang/fix-15126-add-taosd---help-feature
feature(shell): add taosd --help feature.
This commit is contained in:
commit
ccf57cfd14
|
@ -17,11 +17,21 @@
|
||||||
#include "dmImp.h"
|
#include "dmImp.h"
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
|
|
||||||
|
#define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'."
|
||||||
|
#define DM_CFG_DIR "Configuration directory."
|
||||||
|
#define DM_DMP_CFG "Dump configuration."
|
||||||
|
#define DM_ENV_CMD "The env cmd variable string to use when configuring the server, such as: -e 'TAOS_FQDN=td1'."
|
||||||
|
#define DM_ENV_FILE "The env variable file path to use when configuring the server, default is './.env', .env text can be 'TAOS_FQDN=td1'."
|
||||||
|
#define DM_NODE_TYPE "Startup type of the node, default is 0."
|
||||||
|
#define DM_MACHINE_CODE "Get machine code."
|
||||||
|
#define DM_VERSION "Print program version."
|
||||||
|
#define DM_EMAIL "<support@taosdata.com>"
|
||||||
static struct {
|
static struct {
|
||||||
bool dumpConfig;
|
bool dumpConfig;
|
||||||
bool generateGrant;
|
bool generateGrant;
|
||||||
bool printAuth;
|
bool printAuth;
|
||||||
bool printVersion;
|
bool printVersion;
|
||||||
|
bool printHelp;
|
||||||
char envFile[PATH_MAX];
|
char envFile[PATH_MAX];
|
||||||
char apolloUrl[PATH_MAX];
|
char apolloUrl[PATH_MAX];
|
||||||
const char **envCmd;
|
const char **envCmd;
|
||||||
|
@ -91,6 +101,8 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
||||||
} else if (strcmp(argv[i], "-e") == 0) {
|
} else if (strcmp(argv[i], "-e") == 0) {
|
||||||
global.envCmd[cmdEnvIndex] = argv[++i];
|
global.envCmd[cmdEnvIndex] = argv[++i];
|
||||||
cmdEnvIndex++;
|
cmdEnvIndex++;
|
||||||
|
} else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--usage") == 0 || strcmp(argv[i], "-?")) {
|
||||||
|
global.printHelp = true;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +123,21 @@ static void dmPrintVersion() {
|
||||||
printf("buildInfo: %s\n", buildinfo);
|
printf("buildInfo: %s\n", buildinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dmPrintHelp() {
|
||||||
|
char indent[] = " ";
|
||||||
|
printf("Usage: taosd [OPTION...] \n\n");
|
||||||
|
printf("%s%s%s%s\n", indent, "-a,", indent, DM_APOLLO_URL);
|
||||||
|
printf("%s%s%s%s\n", indent, "-c,", indent, DM_CFG_DIR);
|
||||||
|
printf("%s%s%s%s\n", indent, "-C,", indent, DM_DMP_CFG);
|
||||||
|
printf("%s%s%s%s\n", indent, "-e,", indent, DM_ENV_CMD);
|
||||||
|
printf("%s%s%s%s\n", indent, "-E,", indent, DM_ENV_FILE);
|
||||||
|
printf("%s%s%s%s\n", indent, "-n,", indent, DM_NODE_TYPE);
|
||||||
|
printf("%s%s%s%s\n", indent, "-k,", indent, DM_MACHINE_CODE);
|
||||||
|
printf("%s%s%s%s\n", indent, "-V,", indent, DM_VERSION);
|
||||||
|
|
||||||
|
printf("\n\nReport bugs to %s.\n", DM_EMAIL);
|
||||||
|
}
|
||||||
|
|
||||||
static void dmDumpCfg() {
|
static void dmDumpCfg() {
|
||||||
SConfig *pCfg = taosGetCfg();
|
SConfig *pCfg = taosGetCfg();
|
||||||
cfgDumpCfg(pCfg, 0, true);
|
cfgDumpCfg(pCfg, 0, true);
|
||||||
|
@ -197,6 +224,12 @@ int main(int argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (global.printHelp) {
|
||||||
|
dmPrintHelp();
|
||||||
|
taosCleanupArgs();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (global.printVersion) {
|
if (global.printVersion) {
|
||||||
dmPrintVersion();
|
dmPrintVersion();
|
||||||
taosCleanupArgs();
|
taosCleanupArgs();
|
||||||
|
|
Loading…
Reference in New Issue