mute-console: convert to VERB_COMMAND and add --introspect-cli

The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-15 15:30:02 +02:00
parent 548c9cd71c
commit 6fc95be4a2
2 changed files with 12 additions and 31 deletions
+11 -31
View File
@@ -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);
@@ -30,6 +30,7 @@ INTROSPECTABLE=(
systemd-id128
systemd-imds
systemd-inhibit
systemd-mute-console
systemd-notify
systemd-veritysetup
timedatectl