From 6fc95be4a2d1b570d1348f1a796303abb9eab7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 15 Aug 2026 12:51:53 +0200 Subject: [PATCH] mute-console: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. --- src/mute-console/mute-console.c | 42 +++++-------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/mute-console/mute-console.c b/src/mute-console/mute-console.c index b64c66e14f..7ea1fcf17b 100644 --- a/src/mute-console/mute-console.c +++ b/src/mute-console/mute-console.c @@ -4,57 +4,34 @@ #include "sd-bus.h" #include "sd-event.h" +#include "sd-json.h" #include "sd-varlink.h" #include "alloc-util.h" -#include "ansi-color.h" #include "build.h" #include "bus-error.h" #include "bus-locator.h" #include "bus-util.h" #include "daemon-util.h" #include "errno-util.h" -#include "format-table.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "parse-argument.h" -#include "pretty-print.h" #include "printk-util.h" #include "varlink-io.systemd.MuteConsole.h" #include "varlink-util.h" +#include "verbs.h" #include "virt.h" static bool arg_mute_pid1 = true; static bool arg_mute_kernel = true; static bool arg_varlink = false; -static int help(void) { - _cleanup_free_ char *link = NULL; - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = terminal_urlify_man("systemd-mute-console", "1", &link); - if (r < 0) - return log_oom(); - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - printf("%s [OPTIONS...]\n\n" - "%sMute status output to the console.%s\n\n", - program_invocation_short_name, - ansi_highlight(), - ansi_normal()); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - printf("\nSee the %s for details.\n", link); - return 0; -} +COMMAND( + "systemd-mute-console\0", + "Mute status output to the console.", + .man_pages = "systemd-mute-console.1\0", +); static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); @@ -67,7 +44,7 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-mute-console"); OPTION_COMMON_VERSION: return version(); @@ -83,6 +60,9 @@ static int parse_argv(int argc, char *argv[]) { if (r < 0) return r; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } r = sd_varlink_invocation(SD_VARLINK_ALLOW_ACCEPT); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 7deb2c0628..9f4cb68c48 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -30,6 +30,7 @@ INTROSPECTABLE=( systemd-id128 systemd-imds systemd-inhibit + systemd-mute-console systemd-notify systemd-veritysetup timedatectl