From 0059c3f5f249a977ce0fe89e59937452e507925d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 24 Jul 2026 15:35:00 +0200 Subject: [PATCH] verbs: introduce VERB_COMMON_HELP_AUTO{,_HIDDEN} --- src/id128/id128.c | 9 ++------- src/shared/verbs.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/id128/id128.c b/src/id128/id128.c index 7ddbdffbef..20490ef5b9 100644 --- a/src/id128/id128.c +++ b/src/id128/id128.c @@ -14,7 +14,6 @@ #include "main-func.h" #include "options.h" #include "parse-argument.h" -#include "pretty-print.h" #include "string-util.h" #include "strv.h" #include "verbs.h" @@ -234,11 +233,7 @@ static int verb_show(int argc, char *argv[], uintptr_t _data, void *userdata) { return 0; } -static int help(void) { - return command_print_help("systemd-id128"); -} - -VERB_COMMON_HELP(help); +VERB_COMMON_HELP_AUTO("systemd-id128"); static int parse_argv(int argc, char *argv[], char ***ret_args) { int r; @@ -251,7 +246,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { FOREACH_OPTION_OR_RETURN(c, &opts) switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-id128"); OPTION_COMMON_VERSION: return version(); diff --git a/src/shared/verbs.h b/src/shared/verbs.h index 0cbaba8203..59fb8a3951 100644 --- a/src/shared/verbs.h +++ b/src/shared/verbs.h @@ -125,6 +125,12 @@ int _verbs_get_help_table( VERB(verb_help, "help", NULL, VERB_ANY, VERB_ANY, 0, NULL); \ _VERB_COMMON_HELP_IMPL(impl) +#define VERB_COMMON_HELP_AUTO(program) \ + VERB_FULL(verb_help_auto, "help", NULL, VERB_ANY, VERB_ANY, 0, (uintptr_t) program, "Show this help") + +#define VERB_COMMON_HELP_AUTO_HIDDEN(program) \ + VERB_FULL(verb_help_auto, "help", NULL, VERB_ANY, VERB_ANY, 0, (uintptr_t) program, NULL) + int _command_print_help( const Verb verbs[], const Verb verbs_end[], @@ -136,3 +142,7 @@ int _command_print_help( __start_SYSTEMD_VERBS, __stop_SYSTEMD_VERBS, \ __start_SYSTEMD_OPTIONS, __stop_SYSTEMD_OPTIONS, \ name) + +static inline int verb_help_auto(int argc, char **argv, uintptr_t data, void *userdata) { + return command_print_help((const char*) ASSERT_PTR(data)); +}