From c62bfac025a11c8653c6cbdf51a666cb4e4fc1b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:45:03 +0200 Subject: [PATCH 01/17] udev/iocost: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The tool has no man page of its own, so iocost.conf(5), which describes it, is referenced. The test now also looks for commands in /usr/lib/udev, where the udev helpers are installed. --- src/udev/iocost/iocost.c | 43 ++++++------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 7 +-- 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/src/udev/iocost/iocost.c b/src/udev/iocost/iocost.c index a591ba40c0..9da7e1e9a8 100644 --- a/src/udev/iocost/iocost.c +++ b/src/udev/iocost/iocost.c @@ -3,6 +3,7 @@ #include #include "sd-device.h" +#include "sd-json.h" #include "alloc-util.h" #include "build.h" @@ -10,10 +11,7 @@ #include "conf-parser.h" #include "device-util.h" #include "devnum-util.h" -#include "format-table.h" -#include "help-util.h" #include "main-func.h" -#include "options.h" #include "string-util.h" #include "strv.h" #include "udev-util.h" @@ -22,6 +20,12 @@ static char *arg_target_solution = NULL; STATIC_DESTRUCTOR_REGISTER(arg_target_solution, freep); +COMMAND( + "iocost\0", + "Set up iocost model and qos solutions for block devices.", + .man_pages = "iocost.conf.5\0", +); + static int parse_config(void) { static const ConfigTableItem items[] = { { "IOCost", "TargetSolution", config_parse_string, 0, &arg_target_solution }, @@ -51,33 +55,7 @@ static int parse_config(void) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - r = verbs_get_help_table(&verbs); - if (r < 0) - return r; - - (void) table_sync_column_widths(0, options, verbs); - - help_cmdline("[OPTIONS...] COMMAND"); - help_abstract("Set up iocost model and qos solutions for block devices."); - - help_section("Commands"); - r = table_print_or_warn(verbs); - if (r < 0) - return r; - - help_section("Options"); - return table_print_or_warn(options); -} - -VERB_COMMON_HELP_HIDDEN(help); +VERB_COMMON_HELP_AUTO_HIDDEN("iocost"); static int parse_argv(int argc, char *argv[], char ***remaining_args) { assert(argc >= 0); @@ -90,10 +68,13 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("iocost"); OPTION_COMMON_VERSION: return version(); + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } *remaining_args = option_parser_get_args(&opts); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 8da538ef12..4a9728c886 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -3,9 +3,9 @@ set -eux set -o pipefail -# Some commands are in $PATH, others are in our private directory. -# Check the other location too. -PATH=$PATH:/usr/lib/systemd +# Some commands are in $PATH, others are in our private directories. +# Check the other locations too. +PATH=$PATH:/usr/lib/systemd:/usr/lib/udev export SYSTEMD_PAGER=cat @@ -17,6 +17,7 @@ INTROSPECTABLE=( homectl hostnamectl importctl + iocost journalctl localectl loginctl From 43c9d274e9564a9f439dd4390fa2c3f4dcfc185c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:45:28 +0200 Subject: [PATCH 02/17] udev/ata_id: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The help output had no abstract, so one is added. There is no man page for this udev helper, so none is referenced. --- src/udev/ata_id/ata_id.c | 31 ++++++++----------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index 1cde89ad6f..78c403c08b 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -13,24 +13,30 @@ #include #include +#include "sd-json.h" + #include "build.h" #include "device-nodes.h" #include "errno-util.h" #include "fd-util.h" -#include "format-table.h" -#include "help-util.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "strv.h" #include "udev-util.h" #include "unaligned.h" +#include "verbs.h" #define COMMAND_TIMEOUT_MSEC (30 * 1000) static bool arg_export = false; static const char *arg_device = NULL; +COMMAND( + "ata_id\0", + "Identify ATA storage devices.", + .argspec = "DEVICE\0", +); + static int disk_scsi_inquiry_command( int fd, void *buf, @@ -359,20 +365,6 @@ static int disk_identify(int fd, return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...] DEVICE"); - help_section("Options"); - - return table_print_or_warn(options); -} - static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); @@ -383,7 +375,7 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("ata_id"); OPTION_COMMON_VERSION: return version(); @@ -392,6 +384,9 @@ static int parse_argv(int argc, char *argv[]) { "Print values as environment keys"): arg_export = true; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } char **args = option_parser_get_args(&opts); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 4a9728c886..f4b65b4c24 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -11,6 +11,7 @@ export SYSTEMD_PAGER=cat # A smoke test for the introspection code INTROSPECTABLE=( + ata_id bootctl busctl coredumpctl From cc139a73b8a77569e3f5c49f2ef9a65db163c773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:46:04 +0200 Subject: [PATCH 03/17] udev/cdrom_id: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The help output had no abstract, so one is added. There is no man page for this udev helper, so none is referenced. --- src/udev/cdrom_id/cdrom_id.c | 31 ++++++++----------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index 4708b56325..22a723d119 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -8,14 +8,13 @@ #include #include +#include "sd-json.h" + #include "alloc-util.h" #include "build.h" #include "errno-util.h" #include "fd-util.h" -#include "format-table.h" -#include "help-util.h" #include "main-func.h" -#include "options.h" #include "random-util.h" #include "sort-util.h" #include "string-table.h" @@ -24,12 +23,19 @@ #include "time-util.h" #include "udev-util.h" #include "unaligned.h" +#include "verbs.h" static bool arg_eject = false; static bool arg_lock = false; static bool arg_unlock = false; static const char *arg_node = NULL; +COMMAND( + "cdrom_id\0", + "Identify CD/DVD drives and their media.", + .argspec = "DEVICE\0", +); + typedef enum Feature { FEATURE_RW_NONREMOVABLE = 0x01, FEATURE_RW_REMOVABLE = 0x02, @@ -900,20 +906,6 @@ static void print_properties(const Context *c) { printf("ID_CDROM_MEDIA_TRACK_COUNT_DATA=%u\n", c->media_track_count_data); } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...] DEVICE"); - help_section("Options"); - - return table_print_or_warn(options); -} - static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); @@ -924,7 +916,7 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("cdrom_id"); OPTION_COMMON_VERSION: return version(); @@ -950,6 +942,9 @@ static int parse_argv(int argc, char *argv[]) { log_set_max_level(LOG_DEBUG); log_open(); break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } char **args = option_parser_get_args(&opts); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index f4b65b4c24..74ecc5718c 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -14,6 +14,7 @@ INTROSPECTABLE=( ata_id bootctl busctl + cdrom_id coredumpctl homectl hostnamectl From c90fafdd046e75ef36de66e0af6d07a57d7cba41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:46:04 +0200 Subject: [PATCH 04/17] udev/dmi_memory_id: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The help output had no abstract, so one is added. There is no man page for this udev helper, so none is referenced. --- src/udev/dmi_memory_id/dmi_memory_id.c | 30 ++++++++----------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/udev/dmi_memory_id/dmi_memory_id.c b/src/udev/dmi_memory_id/dmi_memory_id.c index 64af7b8028..b39981dbf9 100644 --- a/src/udev/dmi_memory_id/dmi_memory_id.c +++ b/src/udev/dmi_memory_id/dmi_memory_id.c @@ -44,17 +44,17 @@ #include +#include "sd-json.h" + #include "alloc-util.h" #include "build.h" #include "fileio.h" -#include "format-table.h" -#include "help-util.h" #include "main-func.h" -#include "options.h" #include "string-util.h" #include "udev-util.h" #include "unaligned.h" #include "utf8.h" +#include "verbs.h" #define SUPPORTED_SMBIOS_VER 0x030300 @@ -81,6 +81,11 @@ struct dmi_header { static const char *arg_source_file = NULL; +COMMAND( + "dmi_memory_id\0", + "Identify memory devices from DMI/SMBIOS data.", +); + static bool verify_checksum(const uint8_t *buf, size_t len) { uint8_t sum = 0; @@ -644,20 +649,6 @@ static int legacy_decode(const uint8_t *buf, const char *devmem, bool no_file_of devmem, no_file_offset); } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...]"); - help_section("Options"); - - return table_print_or_warn(options); -} - static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); @@ -668,7 +659,7 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("dmi_memory_id"); OPTION_COMMON_VERSION_WITH_HIDDEN_V: return version(); @@ -677,6 +668,9 @@ static int parse_argv(int argc, char *argv[]) { "Read DMI information from a binary file"): arg_source_file = opts.arg; 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 74ecc5718c..65c65b21cb 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -16,6 +16,7 @@ INTROSPECTABLE=( busctl cdrom_id coredumpctl + dmi_memory_id homectl hostnamectl importctl From 5b745242c5567468ef51564046ab4ed57c6928ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:46:05 +0200 Subject: [PATCH 05/17] udev/fido_id: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. There is no man page for this udev helper, so none is referenced. --- src/udev/fido_id/fido_id.c | 30 ++++++++----------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/udev/fido_id/fido_id.c b/src/udev/fido_id/fido_id.c index 30bc96c526..96bdcbd6c1 100644 --- a/src/udev/fido_id/fido_id.c +++ b/src/udev/fido_id/fido_id.c @@ -11,37 +11,28 @@ #include #include +#include "sd-json.h" + #include "alloc-util.h" #include "build.h" #include "device-private.h" #include "device-util.h" #include "fd-util.h" #include "fido_id_desc.h" -#include "format-table.h" -#include "help-util.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "path-util.h" #include "strv.h" #include "udev-util.h" +#include "verbs.h" static const char *arg_device = NULL; -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...] SYSFS_PATH"); - help_abstract("Identify FIDO security tokens."); - help_section("Options"); - - return table_print_or_warn(options); -} +COMMAND( + "fido_id\0", + "Identify FIDO security tokens.", + .argspec = "[SYSFS_PATH]\0", +); static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); @@ -53,10 +44,13 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("fido_id"); OPTION_COMMON_VERSION: return version(); + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } char **args = option_parser_get_args(&opts); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 65c65b21cb..47329ab121 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -17,6 +17,7 @@ INTROSPECTABLE=( cdrom_id coredumpctl dmi_memory_id + fido_id homectl hostnamectl importctl From 7038981d86dac40abb041f2be94c186c88f5cb1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:46:05 +0200 Subject: [PATCH 06/17] udev/mtd_probe: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. There is no man page for this udev helper, so none is referenced. --- src/udev/mtd_probe/mtd_probe.c | 30 ++++++++----------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/udev/mtd_probe/mtd_probe.c b/src/udev/mtd_probe/mtd_probe.c index 7280573646..cc14475743 100644 --- a/src/udev/mtd_probe/mtd_probe.c +++ b/src/udev/mtd_probe/mtd_probe.c @@ -22,33 +22,24 @@ #include #include +#include "sd-json.h" + #include "build.h" #include "errno-util.h" #include "fd-util.h" -#include "format-table.h" -#include "help-util.h" #include "log.h" #include "main-func.h" #include "mtd_probe.h" -#include "options.h" #include "strv.h" +#include "verbs.h" static const char *arg_device = NULL; -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...] /dev/mtd[n]"); - help_abstract("Probe MTD devices."); - help_section("Options"); - - return table_print_or_warn(options); -} +COMMAND( + "mtd_probe\0", + "Probe MTD devices.", + .argspec = "/dev/mtdN\0", +); static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); @@ -60,10 +51,13 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("mtd_probe"); OPTION_COMMON_VERSION: return version(); + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } char **args = option_parser_get_args(&opts); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 47329ab121..34cc54269d 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -26,6 +26,7 @@ INTROSPECTABLE=( localectl loginctl machinectl + mtd_probe networkctl oomctl portablectl From 9cd507ed5b661f64ddea9d8c85fd67bd4db1e952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:46:05 +0200 Subject: [PATCH 07/17] udev/v4l_id: 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 to the imperative. There is no man page for this udev helper, so none is referenced. --- src/udev/v4l_id/v4l_id.c | 30 ++++++++----------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/udev/v4l_id/v4l_id.c b/src/udev/v4l_id/v4l_id.c index f1f40324de..45a1f52bd2 100644 --- a/src/udev/v4l_id/v4l_id.c +++ b/src/udev/v4l_id/v4l_id.c @@ -8,34 +8,25 @@ #include #include +#include "sd-json.h" + #include "build.h" #include "errno-util.h" #include "fd-util.h" -#include "format-table.h" -#include "help-util.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "string-util.h" #include "strv.h" #include "utf8.h" +#include "verbs.h" static const char *arg_device = NULL; -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...] DEVICE"); - help_abstract("Video4Linux device identification."); - help_section("Options"); - - return table_print_or_warn(options); -} +COMMAND( + "v4l_id\0", + "Identify Video4Linux devices.", + .argspec = "DEVICE\0", +); static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); @@ -47,10 +38,13 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("v4l_id"); OPTION_COMMON_VERSION: return version(); + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } char **args = option_parser_get_args(&opts); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 34cc54269d..2ca370c8a1 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -109,6 +109,7 @@ INTROSPECTABLE=( timedatectl updatectl userdbctl + v4l_id varlinkctl ) From df618014a59aabdb753ec4fa40bbbdfe90dcbc18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:46:33 +0200 Subject: [PATCH 08/17] udev/scsi_id: 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 to the imperative. There is no man page for this udev helper, so none is referenced. --- src/udev/scsi_id/scsi_id.c | 32 ++++++++----------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index 93b65816e4..bee527962b 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -8,16 +8,15 @@ #include #include +#include "sd-json.h" + #include "alloc-util.h" #include "build.h" #include "device-nodes.h" #include "extract-word.h" #include "fd-util.h" #include "fileio.h" -#include "format-table.h" -#include "help-util.h" #include "main-func.h" -#include "options.h" #include "parse-util.h" #include "scsi_id.h" #include "string-util.h" @@ -25,6 +24,7 @@ #include "strxcpyx.h" #include "udev-util.h" #include "utf8.h" +#include "verbs.h" static bool all_good = false; static bool dev_specified = false; @@ -40,6 +40,12 @@ static char model_enc_str[256]; static char revision_str[16]; static char type_str[16]; +COMMAND( + "scsi_id\0", + "Identify SCSI devices.", + .argspec = "[DEVICE]\0", +); + static void set_type(unsigned type_num, char *to, size_t len) { const char *type; @@ -206,21 +212,6 @@ static int parse_page_code(const char *value, enum page_code *ret) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTION...] DEVICE"); - help_abstract("SCSI device identification."); - help_section("Options"); - - return table_print_or_warn(options); -} - static int set_options(int argc, char **argv, char *maj_min_dev) { assert(argc >= 0); assert(argv); @@ -232,7 +223,7 @@ static int set_options(int argc, char **argv, char *maj_min_dev) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("scsi_id"); OPTION_COMMON_VERSION_WITH_HIDDEN_V: return version(); @@ -284,6 +275,9 @@ static int set_options(int argc, char **argv, char *maj_min_dev) { OPTION('x', "export", NULL, "Print values as environment keys"): export = true; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } char **args = option_parser_get_args(&opts); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 2ca370c8a1..3f47151538 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=( portablectl resolvectl run0 + scsi_id storagectl systemd-ac-power systemd-analyze From 3a45066bcecfb5fdd93587df8b91d7318a4134e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:44:05 +0200 Subject: [PATCH 09/17] export: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. There is no man page for this internal helper, so none is referenced. --- src/import/export.c | 54 ++++--------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 12 insertions(+), 43 deletions(-) diff --git a/src/import/export.c b/src/import/export.c index 2e1576c467..9ad625e8b3 100644 --- a/src/import/export.c +++ b/src/import/export.c @@ -4,20 +4,18 @@ #include #include "sd-event.h" +#include "sd-json.h" #include "alloc-util.h" -#include "ansi-color.h" #include "build.h" #include "discover-image.h" #include "dlopen-note.h" #include "export-raw.h" #include "export-tar.h" #include "fd-util.h" -#include "format-table.h" #include "import-common.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "runtime-scope.h" #include "signal-util.h" #include "string-util.h" @@ -29,6 +27,11 @@ static Compression arg_compress = _COMPRESSION_INVALID; static ImageClass arg_class = IMAGE_MACHINE; static RuntimeScope arg_runtime_scope = _RUNTIME_SCOPE_INVALID; +COMMAND( + "systemd-export\0", + "Export disk images.", +); + static void determine_compression_from_filename(const char *p) { if (arg_compress >= 0) return; @@ -194,45 +197,7 @@ static int verb_export_raw(int argc, char *argv[], uintptr_t _data, void *userda return -r; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL; - int r; - - 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, verbs, options); - - printf("%s [OPTIONS...] {COMMAND} ...\n\n" - "%sExport disk images.%s\n" - "\n%sCommands:%s\n", - program_invocation_short_name, - ansi_highlight(), - ansi_normal(), - ansi_underline(), - ansi_normal()); - - r = table_print_or_warn(verbs); - if (r < 0) - return r; - - printf("\n%sOptions:%s\n", - ansi_underline(), - ansi_normal()); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - return 0; -} - -VERB_COMMON_HELP_HIDDEN(help); +VERB_COMMON_HELP_AUTO_HIDDEN("systemd-export"); static int parse_argv(int argc, char *argv[], char ***ret_args) { assert(argc >= 0); @@ -245,7 +210,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-export"); OPTION_COMMON_VERSION: return version(); @@ -271,6 +236,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { OPTION_COMMON_USER: arg_runtime_scope = RUNTIME_SCOPE_USER; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } if (arg_runtime_scope == RUNTIME_SCOPE_USER) diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 3f47151538..96dcc7da09 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -54,6 +54,7 @@ INTROSPECTABLE=( systemd-detect-virt systemd-dissect systemd-escape + systemd-export systemd-factory-reset systemd-firstboot systemd-growfs From 3e61b718a5e9c188e94fdcd3683eead52b182ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:44:44 +0200 Subject: [PATCH 10/17] import: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. There is no man page for this internal helper, so none is referenced. --- src/import/import.c | 54 ++++--------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 12 insertions(+), 43 deletions(-) diff --git a/src/import/import.c b/src/import/import.c index 782557a221..2b4aad9b05 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -4,22 +4,20 @@ #include #include "sd-event.h" +#include "sd-json.h" #include "alloc-util.h" -#include "ansi-color.h" #include "build.h" #include "discover-image.h" #include "dlopen-note.h" #include "env-util.h" #include "fd-util.h" -#include "format-table.h" #include "import-raw.h" #include "import-tar.h" #include "import-util.h" #include "io-util.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "parse-argument.h" #include "parse-util.h" #include "path-util.h" @@ -36,6 +34,11 @@ static RuntimeScope arg_runtime_scope = _RUNTIME_SCOPE_INVALID; STATIC_DESTRUCTOR_REGISTER(arg_image_root, freep); +COMMAND( + "systemd-import\0", + "Import disk images.", +); + static int normalize_local(const char *local, char **ret) { _cleanup_free_ char *ll = NULL; int r; @@ -272,45 +275,7 @@ static int verb_raw(int argc, char *argv[], uintptr_t _data, void *userdata) { return -r; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL; - int r; - - 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, verbs, options); - - printf("%s [OPTIONS...] {COMMAND} ...\n\n" - "%sImport disk images.%s\n" - "\n%sCommands:%s\n", - program_invocation_short_name, - ansi_highlight(), - ansi_normal(), - ansi_underline(), - ansi_normal()); - - r = table_print_or_warn(verbs); - if (r < 0) - return r; - - printf("\n%sOptions:%s\n", - ansi_underline(), - ansi_normal()); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - return 0; -} - -VERB_COMMON_HELP_HIDDEN(help); +VERB_COMMON_HELP_AUTO_HIDDEN("systemd-import"); static int parse_argv(int argc, char *argv[], char ***ret_args) { int r; @@ -324,7 +289,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-import"); OPTION_COMMON_VERSION: return version(); @@ -418,6 +383,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { OPTION_COMMON_USER: arg_runtime_scope = RUNTIME_SCOPE_USER; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } /* Make sure offset+size is still in the valid range if both set */ diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 96dcc7da09..b43150d6c0 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -63,6 +63,7 @@ INTROSPECTABLE=( systemd-id128 systemd-imds systemd-imdsd + systemd-import systemd-inhibit systemd-journal-gatewayd systemd-journal-remote From 9832927a08bd215936ca9de50e939d9f28a40bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:44:44 +0200 Subject: [PATCH 11/17] import-fs: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. There is no man page for this internal helper, so none is referenced. --- src/import/import-fs.c | 55 ++++--------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 13 insertions(+), 43 deletions(-) diff --git a/src/import/import-fs.c b/src/import/import-fs.c index 72d6fef877..a4ea7e6b1a 100644 --- a/src/import/import-fs.c +++ b/src/import/import-fs.c @@ -3,15 +3,15 @@ #include #include +#include "sd-json.h" + #include "alloc-util.h" -#include "ansi-color.h" #include "btrfs-util.h" #include "build.h" #include "copy.h" #include "discover-image.h" #include "dlopen-note.h" #include "fd-util.h" -#include "format-table.h" #include "format-util.h" #include "import-common.h" #include "import-util.h" @@ -19,7 +19,6 @@ #include "log.h" #include "main-func.h" #include "mkdir.h" -#include "options.h" #include "parse-argument.h" #include "path-util.h" #include "ratelimit.h" @@ -43,6 +42,11 @@ static RuntimeScope arg_runtime_scope = _RUNTIME_SCOPE_INVALID; STATIC_DESTRUCTOR_REGISTER(arg_image_root, freep); +COMMAND( + "systemd-import-fs\0", + "Import container images from file system directories.", +); + typedef struct ProgressInfo { RateLimit limit; char *path; @@ -268,45 +272,7 @@ static int verb_import_fs(int argc, char *argv[], uintptr_t _data, void *userdat return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL; - int r; - - 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, verbs, options); - - printf("%s [OPTIONS...] {COMMAND} ...\n\n" - "%sImport container images from file system directories.%s\n" - "\n%sCommands:%s\n", - program_invocation_short_name, - ansi_highlight(), - ansi_normal(), - ansi_underline(), - ansi_normal()); - - r = table_print_or_warn(verbs); - if (r < 0) - return r; - - printf("\n%sOptions:%s\n", - ansi_underline(), - ansi_normal()); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - return 0; -} - -VERB_COMMON_HELP_HIDDEN(help); +VERB_COMMON_HELP_AUTO_HIDDEN("systemd-import-fs"); static int parse_argv(int argc, char *argv[], char ***ret_args) { assert(argc >= 0); @@ -320,7 +286,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-import-fs"); OPTION_COMMON_VERSION: return version(); @@ -377,6 +343,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { OPTION_COMMON_USER: arg_runtime_scope = RUNTIME_SCOPE_USER; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } if (!arg_image_root) { diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index b43150d6c0..b9ca286b8d 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -64,6 +64,7 @@ INTROSPECTABLE=( systemd-imds systemd-imdsd systemd-import + systemd-import-fs systemd-inhibit systemd-journal-gatewayd systemd-journal-remote From c226b876c0a72bd1d947845b82a4ae7fea347a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:44:45 +0200 Subject: [PATCH 12/17] pull: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. There is no man page for this internal helper, so none is referenced. --- src/import/pull.c | 55 ++++--------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 12 insertions(+), 44 deletions(-) diff --git a/src/import/pull.c b/src/import/pull.c index 92296c4fed..30b87c6d88 100644 --- a/src/import/pull.c +++ b/src/import/pull.c @@ -1,17 +1,15 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include #include "sd-event.h" +#include "sd-json.h" #include "alloc-util.h" -#include "ansi-color.h" #include "build.h" #include "discover-image.h" #include "dlopen-note.h" #include "env-util.h" -#include "format-table.h" #include "hexdecoct.h" #include "import-common.h" #include "import-util.h" @@ -20,7 +18,6 @@ #include "log.h" #include "main-func.h" #include "oci-util.h" -#include "options.h" #include "parse-argument.h" #include "parse-util.h" #include "path-util.h" @@ -44,6 +41,11 @@ static RuntimeScope arg_runtime_scope = _RUNTIME_SCOPE_INVALID; STATIC_DESTRUCTOR_REGISTER(arg_checksum, iovec_done); STATIC_DESTRUCTOR_REGISTER(arg_image_root, freep); +COMMAND( + "systemd-pull\0", + "Download disk images.", +); + static int normalize_local(const char *local, const char *url, char **ret) { _cleanup_free_ char *ll = NULL; int r; @@ -318,45 +320,7 @@ static int verb_oci(int argc, char *argv[], uintptr_t _data, void *userdata) { return -r; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL; - int r; - - 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, verbs, options); - - printf("%s [OPTIONS...] {COMMAND} ...\n\n" - "%sDownload disk images.%s\n" - "\n%sCommands:%s\n", - program_invocation_short_name, - ansi_highlight(), - ansi_normal(), - ansi_underline(), - ansi_normal()); - - r = table_print_or_warn(verbs); - if (r < 0) - return r; - - printf("\n%sOptions:%s\n", - ansi_underline(), - ansi_normal()); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - return 0; -} - -VERB_COMMON_HELP_HIDDEN(help); +VERB_COMMON_HELP_AUTO_HIDDEN("systemd-pull"); static int parse_argv(int argc, char *argv[], char ***ret_args) { int r; @@ -371,7 +335,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-pull"); OPTION_COMMON_VERSION: return version(); @@ -545,6 +509,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { OPTION_COMMON_USER: arg_runtime_scope = RUNTIME_SCOPE_USER; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } /* Make sure offset+size is still in the valid range if both set */ diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index b9ca286b8d..8b3da23052 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -84,6 +84,7 @@ INTROSPECTABLE=( systemd-pcrextend systemd-pcrlock systemd-pty-forward + systemd-pull systemd-random-seed systemd-repart systemd-report From 45966bcf8ed92d67434b6592be44c58440eefcc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:47:25 +0200 Subject: [PATCH 13/17] report-basic: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The abstract gets a trailing period. There is no man page for this helper, so none is referenced. --- src/report/report-basic-server.c | 35 ++++++------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/report/report-basic-server.c b/src/report/report-basic-server.c index e65481a190..4db1552a55 100644 --- a/src/report/report-basic-server.c +++ b/src/report/report-basic-server.c @@ -1,16 +1,20 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "sd-json.h" #include "sd-varlink.h" -#include "ansi-color.h" #include "build.h" -#include "format-table.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "report-basic.h" #include "varlink-io.systemd.Metrics.h" #include "varlink-util.h" +#include "verbs.h" + +COMMAND( + "systemd-report-basic\0", + "Generate a report describing the current system.", +); static int vl_server(void) { _cleanup_(sd_varlink_server_unrefp) sd_varlink_server *vs = NULL; @@ -38,26 +42,6 @@ static int vl_server(void) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - printf("%s [OPTIONS...]\n" - "\n%sGenerate a report describing the current system%s\n" - "\n%sOptions:%s\n", - program_invocation_short_name, - ansi_highlight(), - ansi_normal(), - ansi_underline(), - ansi_normal()); - - return table_print_or_warn(options); -} - static int parse_argv(int argc, char *argv[]) { int r; @@ -69,10 +53,13 @@ static int parse_argv(int argc, char *argv[]) { FOREACH_OPTION_OR_RETURN(c, &opts) switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-report-basic"); OPTION_COMMON_VERSION: return version(); + + 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 8b3da23052..aecc77de64 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -88,6 +88,7 @@ INTROSPECTABLE=( systemd-random-seed systemd-repart systemd-report + systemd-report-basic systemd-run systemd-sbsign systemd-sleep From 8f42146976cc2fe61d9aeb24e634645c11a3c540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:47:25 +0200 Subject: [PATCH 14/17] report-cgroup: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The referenced systemd-report-cgroup(8) man page does not exist, so the reference is dropped. --- src/report/report-cgroup-server.c | 35 ++++++------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/report/report-cgroup-server.c b/src/report/report-cgroup-server.c index 279edbb8d1..c6a851ce6a 100644 --- a/src/report/report-cgroup-server.c +++ b/src/report/report-cgroup-server.c @@ -1,16 +1,20 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "sd-json.h" #include "sd-varlink.h" #include "build.h" -#include "format-table.h" -#include "help-util.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "report-cgroup.h" #include "varlink-io.systemd.Metrics.h" #include "varlink-util.h" +#include "verbs.h" + +COMMAND( + "systemd-report-cgroup\0", + "Report cgroup metrics.", +); static int vl_server(void) { _cleanup_(sd_varlink_server_unrefp) sd_varlink_server *vs = NULL; @@ -38,26 +42,6 @@ static int vl_server(void) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...]"); - help_abstract("Report cgroup metrics."); - - help_section("Options"); - r = table_print_or_warn(options); - if (r < 0) - return r; - - help_man_page_reference("systemd-report-cgroup", "8"); - return 0; -} - static int parse_argv(int argc, char *argv[]) { int r; @@ -70,10 +54,13 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-report-cgroup"); OPTION_COMMON_VERSION: return version(); + + 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 aecc77de64..f00080082e 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -89,6 +89,7 @@ INTROSPECTABLE=( systemd-repart systemd-report systemd-report-basic + systemd-report-cgroup systemd-run systemd-sbsign systemd-sleep From 578e5c1b38f3aa4f7fea7f82e8691358e17fa9c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:47:26 +0200 Subject: [PATCH 15/17] report-files: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. --- src/report/report-files-server.c | 36 +++++++------------ .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/report/report-files-server.c b/src/report/report-files-server.c index c1f90ccd7b..70604d5214 100644 --- a/src/report/report-files-server.c +++ b/src/report/report-files-server.c @@ -1,16 +1,21 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "sd-json.h" #include "sd-varlink.h" #include "build.h" -#include "format-table.h" -#include "help-util.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "report-files.h" #include "varlink-io.systemd.Metrics.h" #include "varlink-util.h" +#include "verbs.h" + +COMMAND( + "systemd-report-files\0", + "Report the contents of files as system report metrics.", + .man_pages = "systemd-report-files@.service.8\0", +); static int vl_server(void) { _cleanup_(sd_varlink_server_unrefp) sd_varlink_server *vs = NULL; @@ -38,26 +43,6 @@ static int vl_server(void) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...]"); - help_abstract("Report the contents of files as system report metrics."); - help_section("Options"); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - help_man_page_reference("systemd-report-files@.service", "8"); - return 0; -} - static int parse_argv(int argc, char *argv[]) { int r; @@ -69,10 +54,13 @@ static int parse_argv(int argc, char *argv[]) { FOREACH_OPTION_OR_RETURN(c, &opts) switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-report-files"); OPTION_COMMON_VERSION: return version(); + + 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 f00080082e..4d6e376e62 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -90,6 +90,7 @@ INTROSPECTABLE=( systemd-report systemd-report-basic systemd-report-cgroup + systemd-report-files systemd-run systemd-sbsign systemd-sleep From 8d8cf2cf1ac173e6b719b6159be0032158c4bf74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:47:26 +0200 Subject: [PATCH 16/17] report-sign-plain: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. --- src/report/report-sign-plain.c | 35 ++++++------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/report/report-sign-plain.c b/src/report/report-sign-plain.c index 45f4c86cd6..1f7c760f8c 100644 --- a/src/report/report-sign-plain.c +++ b/src/report/report-sign-plain.c @@ -13,21 +13,25 @@ #include "errno-util.h" #include "fd-util.h" #include "fileio.h" -#include "format-table.h" #include "fs-util.h" -#include "help-util.h" #include "iovec-util.h" #include "json-util.h" #include "lock-util.h" #include "log.h" #include "main-func.h" #include "metrics.h" -#include "options.h" #include "stat-util.h" #include "tmpfile-util.h" #include "varlink-io.systemd.Metrics.h" #include "varlink-io.systemd.Report.Signer.h" #include "varlink-util.h" +#include "verbs.h" + +COMMAND( + "systemd-report-sign-plain\0", + "Sign system reports with a local software key.", + .man_pages = "systemd-report-sign-plain@.service.8\0", +); #define REPORT_SIGN_PLAIN_DIR "/var/lib/systemd/report.sign.plain" #define REPORT_SIGN_PLAIN_PRIVATE_KEY "local.private" @@ -339,26 +343,6 @@ static int vl_server(void) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...]"); - help_abstract("Sign system reports with a local software key."); - help_section("Options"); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - help_man_page_reference("systemd-report-sign-plain@.service", "8"); - return 0; -} - static int parse_argv(int argc, char *argv[]) { int r; @@ -370,10 +354,13 @@ static int parse_argv(int argc, char *argv[]) { FOREACH_OPTION_OR_RETURN(c, &opts) switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-report-sign-plain"); OPTION_COMMON_VERSION: return version(); + + 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 4d6e376e62..2aa0c25870 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -91,6 +91,7 @@ INTROSPECTABLE=( systemd-report-basic systemd-report-cgroup systemd-report-files + systemd-report-sign-plain systemd-run systemd-sbsign systemd-sleep From 963b2323efcb536029ec1823c52b1a8d7ecc7ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 20:47:26 +0200 Subject: [PATCH 17/17] report-sign-tsm: 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 now wrapped automatically. --- src/report/report-sign-tsm.c | 38 +++++++------------ .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/report/report-sign-tsm.c b/src/report/report-sign-tsm.c index 0929fbbc0b..2e9f2b2f40 100644 --- a/src/report/report-sign-tsm.c +++ b/src/report/report-sign-tsm.c @@ -4,18 +4,23 @@ #include "sd-varlink.h" #include "build.h" -#include "format-table.h" -#include "help-util.h" #include "iovec-util.h" #include "json-util.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "sha256.h" #include "string-util.h" #include "tsm-report.h" #include "varlink-io.systemd.Report.Signer.h" #include "varlink-util.h" +#include "verbs.h" + +COMMAND( + "systemd-report-sign-tsm\0", + "Get an attestation report via configfs Trusted Security Module (TSM) " + "that includes the hash of the system report.", + .man_pages = "systemd-report-sign-tsm@.service.8\0", +); typedef struct SignParameters { struct iovec digest; @@ -101,27 +106,6 @@ static int vl_server(void) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...]"); - help_abstract("Get an attestation report via configfs Trusted Security Module (TSM) " - "that includes the hash of the system report."); - help_section("Options"); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - help_man_page_reference("systemd-report-sign-tsm@.service", "8"); - return 0; -} - static int parse_argv(int argc, char *argv[]) { int r; @@ -133,9 +117,13 @@ static int parse_argv(int argc, char *argv[]) { FOREACH_OPTION_OR_RETURN(c, &opts) switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-report-sign-tsm"); + OPTION_COMMON_VERSION: return version(); + + 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 2aa0c25870..4a7d61cae3 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -92,6 +92,7 @@ INTROSPECTABLE=( systemd-report-cgroup systemd-report-files systemd-report-sign-plain + systemd-report-sign-tsm systemd-run systemd-sbsign systemd-sleep