From 55bce8c7c4304da1c459615fcb5a125690d0b058 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 26 Aug 2021 13:53:13 +0800 Subject: [PATCH] [TD-6280]: taosdump -P determine input. --- src/kit/taosdump/taosdump.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index 30b5d91b10..dfebac3622 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -370,6 +370,15 @@ struct arguments g_args = { false // performance_print }; +static void errorPrintReqArg2(char *program, char *wrong_arg) +{ + fprintf(stderr, + "%s: option requires a number argument '-%s'\n", + program, wrong_arg); + fprintf(stderr, + "Try `taosdump --help' or `taosdump --usage' for more information.\n"); +} + /* Parse a single option. */ static error_t parse_opt(int key, char *arg, struct argp_state *state) { /* Get the input argument from argp_parse, which we @@ -390,6 +399,10 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { case 'p': break; case 'P': + if (!isStringNumber(arg)) { + errorPrintReqArg2("taosdump", "P"); + exit(EXIT_FAILURE); + } g_args.port = atoi(arg); break; case 'q': -- GitLab