From ef3bb712a77a4ada0ae1635f71377b98d98698d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 17 Aug 2026 13:37:09 +0200 Subject: [PATCH] report: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. --help now goes through the pager, like other commands with --no-pager. --- src/report/report.c | 49 +++++-------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/src/report/report.c b/src/report/report.c index 82559fff38..86bf9c77d7 100644 --- a/src/report/report.c +++ b/src/report/report.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "sd-event.h" +#include "sd-json.h" #include "sd-varlink.h" #include "alloc-util.h" @@ -9,11 +10,9 @@ #include "dirent-util.h" #include "dlopen-note.h" #include "format-table.h" -#include "help-util.h" #include "json-util.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "parse-argument.h" #include "path-lookup.h" #include "recurse-dir.h" @@ -56,6 +55,13 @@ STATIC_DESTRUCTOR_REGISTER(arg_cert, freep); STATIC_DESTRUCTOR_REGISTER(arg_trust, freep); STATIC_DESTRUCTOR_REGISTER(arg_extra_headers, strv_freep); +COMMAND( + "systemd-report\0", + "Acquire metrics from local sources.", + .man_pages = "systemd-report.1\0", + .pager_flags = &arg_pager_flags, +); + typedef struct LinkInfo { Context *context; sd_varlink *link; @@ -918,39 +924,7 @@ static int vl_server(void) { return 0; } -static int help(void) { - int r; - - _cleanup_(table_unrefp) Table *verbs = NULL, *options = NULL; - r = verbs_get_help_table(&verbs); - if (r < 0) - return r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - (void) table_sync_column_widths(0, options, verbs); - - help_cmdline("[OPTIONS...] COMMAND ..."); - help_abstract("Acquire metrics from local sources."); - help_section("Commands"); - - r = table_print_or_warn(verbs); - if (r < 0) - return r; - - help_section("Options"); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - help_man_page_reference("systemd-report", "1"); - return 0; -} - -VERB_COMMON_HELP_HIDDEN(help); +VERB_COMMON_HELP_AUTO_HIDDEN("systemd-report"); static int parse_argv(int argc, char *argv[], char ***ret_args) { int r; @@ -963,7 +937,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-report"); OPTION_COMMON_VERSION: return version(); @@ -1048,6 +1022,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { if (arg_sign_mode < 0) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse --sign= mode '%s'.", opts.arg); break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(arg_json_format_flags); } if ((arg_url || arg_key || arg_cert || arg_trust || arg_extra_headers) && !HAVE_LIBCURL) diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index ac0fdf964e..0498f7524e 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -62,6 +62,7 @@ INTROSPECTABLE=( systemd-pcrextend systemd-pty-forward systemd-random-seed + systemd-report systemd-socket-activate systemd-socket-proxyd systemd-stdio-bridge