From 6e64a169bd583fa420384d8d3accf376324578e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 16 Aug 2026 14:35:41 +0200 Subject: [PATCH] journal-gatewayd: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The abstract is changed from the noun phrase "HTTP server for journal events." to the imperative "Serve journal events over HTTP.", consistent with the other commands, and the meaningless "..." placeholder is dropped from the synopsis (the tool takes no positional arguments). --- src/journal-remote/journal-gatewayd.c | 41 ++++++------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index f2fd083c8a..e135bf1c9b 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -9,6 +9,7 @@ #include "sd-bus.h" #include "sd-daemon.h" #include "sd-journal.h" +#include "sd-json.h" #include "alloc-util.h" #include "build.h" @@ -16,7 +17,6 @@ #include "errno-util.h" #include "fd-util.h" #include "fileio.h" -#include "format-table.h" #include "glob-util.h" #include "hostname-setup.h" #include "hostname-util.h" @@ -27,15 +27,14 @@ #include "main-func.h" #include "memory-util.h" #include "microhttpd-util.h" -#include "options.h" #include "os-util.h" #include "output-mode.h" #include "parse-util.h" -#include "pretty-print.h" #include "signal-util.h" #include "string-util.h" #include "time-util.h" #include "tmpfile-util.h" +#include "verbs.h" #define JOURNAL_WAIT_TIMEOUT (10*USEC_PER_SEC) @@ -53,6 +52,12 @@ STATIC_DESTRUCTOR_REGISTER(arg_trust_pem, freep); STATIC_DESTRUCTOR_REGISTER(arg_directory, freep); STATIC_DESTRUCTOR_REGISTER(arg_file, strv_freep); +COMMAND( + "systemd-journal-gatewayd\0", + "Serve journal events over HTTP.", + .man_pages = "systemd-journal-gatewayd.service.8\0", +); + typedef struct RequestMeta { sd_journal *journal; @@ -1096,31 +1101,6 @@ static mhd_result request_handler( return mhd_respond(connection, MHD_HTTP_NOT_FOUND, "Not found."); } -static int help(void) { - _cleanup_free_ char *link = NULL; - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = terminal_urlify_man("systemd-journal-gatewayd.service", "8", &link); - if (r < 0) - return log_oom(); - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - printf("%s [OPTIONS...] ...\n\n" - "HTTP server for journal events.\n\n", - program_invocation_short_name); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - printf("\nSee the %s for details.\n", link); - return 0; -} - static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); @@ -1132,7 +1112,7 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-journal-gatewayd"); OPTION_COMMON_VERSION: return version(); @@ -1207,6 +1187,9 @@ static int parse_argv(int argc, char *argv[]) { if (r < 0) return log_error_errno(r, "Failed to add paths: %m"); break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } if (option_parser_get_n_args(&opts) > 0) diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 7d4ca2abce..ca120a7b27 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -36,6 +36,7 @@ INTROSPECTABLE=( systemd-id128 systemd-imds systemd-inhibit + systemd-journal-gatewayd systemd-mute-console systemd-notify systemd-oomd