From 94a955cd31ac95eef8b10adbafb753c61116b8b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 15 Aug 2026 12:52:29 +0200 Subject: [PATCH] oomd: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. --- src/oom/oomd.c | 39 ++++++------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/oom/oomd.c b/src/oom/oomd.c index 7f1a4d0550..4bf29e7af6 100644 --- a/src/oom/oomd.c +++ b/src/oom/oomd.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "sd-event.h" +#include "sd-json.h" #include "alloc-util.h" #include "build.h" @@ -9,43 +10,22 @@ #include "cgroup-util.h" #include "daemon-util.h" #include "fileio.h" -#include "format-table.h" #include "log.h" #include "main-func.h" #include "oomd-conf.h" #include "oomd-manager.h" #include "oomd-manager-bus.h" -#include "options.h" #include "parse-util.h" -#include "pretty-print.h" #include "psi-util.h" +#include "verbs.h" static bool arg_dry_run = false; -static int help(void) { - _cleanup_free_ char *link = NULL; - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = terminal_urlify_man("systemd-oomd", "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" - "Run the userspace out-of-memory (OOM) killer.\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; -} +COMMAND( + "systemd-oomd\0", + "Run the userspace out-of-memory (OOM) killer.", + .man_pages = "systemd-oomd.8\0", +); static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); @@ -57,7 +37,7 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-oomd"); OPTION_COMMON_VERSION: return version(); @@ -74,6 +54,9 @@ static int parse_argv(int argc, char *argv[]) { opts.arg, BUS_IMPLEMENTATIONS(&manager_object, &log_control_object)); + + 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 9f4cb68c48..477f6bdc6b 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -32,6 +32,7 @@ INTROSPECTABLE=( systemd-inhibit systemd-mute-console systemd-notify + systemd-oomd systemd-veritysetup timedatectl varlinkctl