From 54fd8ad1ac459a3fa1d61e435f056f9b7ce56bbf Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Mon, 28 Apr 2025 02:03:40 +0900 Subject: [PATCH] plugin: translate -h into commands As the help short option parsed -h by argconfig so follow plugin also. Signed-off-by: Tokunori Ikegami --- plugin.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin.c b/plugin.c index a5cb4f995a..c7c4481071 100644 --- a/plugin.c +++ b/plugin.c @@ -144,6 +144,7 @@ int handle_plugin(int argc, char **argv, struct plugin *plugin) struct command **cmd = plugin->commands; struct command *cr = NULL; bool cr_valid = false; + int dash_count = 0; if (!argc) { general_help(plugin); @@ -156,11 +157,14 @@ int handle_plugin(int argc, char **argv, struct plugin *plugin) sprintf(use, "%s %s %s [OPTIONS]", prog->name, plugin->name, str); argconfig_append_usage(use); - /* translate --help and --version into commands */ - while (*str == '-') - str++; + /* translate --help, -h and --version into commands */ + while (str[dash_count] == '-') + dash_count++; - if (!strcmp(str, "help")) + if (dash_count) + str += dash_count; + + if (!strcmp(str, "help") || (dash_count == 1 && !strcmp(str, "h"))) return help(argc, argv, plugin); if (!strcmp(str, "version")) return version_cmd(plugin);