diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 43237e6e6c..5983ba92ac 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -17,11 +17,21 @@ #include "dmImp.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 "" static struct { bool dumpConfig; bool generateGrant; bool printAuth; bool printVersion; + bool printHelp; char envFile[PATH_MAX]; char apolloUrl[PATH_MAX]; const char **envCmd; @@ -91,6 +101,8 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) { } else if (strcmp(argv[i], "-e") == 0) { global.envCmd[cmdEnvIndex] = argv[++i]; 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 { } } @@ -111,6 +123,21 @@ static void dmPrintVersion() { 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() { SConfig *pCfg = taosGetCfg(); cfgDumpCfg(pCfg, 0, true); @@ -197,6 +224,12 @@ int main(int argc, char const *argv[]) { return 0; } + if (global.printHelp) { + dmPrintHelp(); + taosCleanupArgs(); + return 0; + } + if (global.printVersion) { dmPrintVersion(); taosCleanupArgs();