From d3055d1fdf08612f8a7500dee63d6eb1b1304e3a Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Tue, 12 Sep 2023 23:45:18 +0900 Subject: [PATCH] util: Fix to set argconfig output format json option correctly Signed-off-by: Tokunori Ikegami --- util/argconfig.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/util/argconfig.c b/util/argconfig.c index 2f3bfc65..35d24f1d 100644 --- a/util/argconfig.c +++ b/util/argconfig.c @@ -340,6 +340,12 @@ static bool argconfig_check_human_readable(struct argconfig_commandline_options return false; } +static void argconfig_parse_short_opt(int c) +{ + if (c == 'j') + argconfig_set_output_format_json(true); +} + int argconfig_parse(int argc, char *argv[], const char *program_desc, struct argconfig_commandline_options *options) { @@ -397,12 +403,15 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc, ret = -EINVAL; break; } - if (c == 'j') - argconfig_set_output_format_json(true); + if (option_index >= options_count) + argconfig_parse_short_opt(c); for (option_index = 0; option_index < options_count; option_index++) { if (c == options[option_index].short_option) break; } + if (option_index == options_count || + !strcmp(options[option_index].option, "json")) + argconfig_parse_short_opt(c); if (option_index == options_count) continue; } -- 2.50.1