udevadm-cat: use common verb help and add --introspect-cli

The custom help() is replaced by the common verb help, which derives the
synopsis, abstract, and option list from the verb declaration in
udevadm.c and the "udevadm-cat" option namespace.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-28 09:29:04 +02:00
parent a35f5d5eba
commit 96b091a6b4
+7 -22
View File
@@ -1,9 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "sd-json.h"
#include "alloc-util.h"
#include "conf-files.h"
#include "format-table.h"
#include "help-util.h"
#include "log.h"
#include "options.h"
#include "parse-argument.h"
@@ -11,6 +11,7 @@
#include "static-destruct.h"
#include "udevadm.h"
#include "udevadm-util.h"
#include "verbs.h"
static char *arg_root = NULL;
static CatFlags arg_cat_flags = 0;
@@ -18,25 +19,6 @@ static bool arg_config = false;
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
static int help(void) {
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = option_parser_get_help_table_ns("udevadm-cat", &options);
if (r < 0)
return r;
help_cmdline("cat [OPTIONS...] [FILE...]");
help_abstract("Show udev rules files.");
help_section("Options");
r = table_print_or_warn(options);
if (r < 0)
return r;
help_man_page_reference("udevadm", "8");
return 0;
}
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
int r;
@@ -52,7 +34,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
OPTION_NAMESPACE("udevadm-cat"): {}
OPTION_COMMON_HELP:
return help();
return command_print_verb_help("cat");
OPTION_COMMON_VERSION_WITH_HIDDEN_V:
return print_version();
@@ -73,6 +55,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
"Show udev.conf rather than udev rules files"):
arg_config = true;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (arg_config && option_parser_get_n_args(&opts) > 0)