From 9da7b27037d471a2a03186882df56aeec47c841f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 16 Aug 2026 14:37:09 +0200 Subject: [PATCH] network-generator: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The old help had neither an abstract nor a man page reference; both are added, with the abstract taken from the man page. --- .../generator/network-generator-main.c | 35 ++++++++----------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/network/generator/network-generator-main.c b/src/network/generator/network-generator-main.c index ae15dff2b1..fb5c54bd13 100644 --- a/src/network/generator/network-generator-main.c +++ b/src/network/generator/network-generator-main.c @@ -2,29 +2,37 @@ #include +#include "sd-json.h" + #include "alloc-util.h" #include "build.h" #include "creds-util.h" #include "dlopen-note.h" #include "errno-util.h" #include "fd-util.h" -#include "format-table.h" #include "fs-util.h" #include "generator.h" #include "log.h" #include "main-func.h" #include "mkdir.h" #include "network-generator.h" -#include "options.h" #include "path-util.h" #include "proc-cmdline.h" #include "string-util.h" #include "strv.h" +#include "verbs.h" #define NETWORK_UNIT_DIRECTORY "/run/systemd/network/" static const char *arg_root = NULL; +COMMAND( + "systemd-network-generator\0", + "Generate network configuration from the kernel command line.", + .argspec = "[-- KERNEL_CMDLINE]\0", + .man_pages = "systemd-network-generator.service.8\0", +); + static int network_save(Network *network, const char *dest_dir) { _cleanup_(unlink_and_freep) char *temp_path = NULL; _cleanup_fclose_ FILE *f = NULL; @@ -150,24 +158,6 @@ static int context_save(Context *context) { return r; } -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...] [-- KERNEL_CMDLINE]\n\n", - program_invocation_short_name); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - return 0; -} - static int parse_argv(int argc, char *argv[], char ***ret_args) { assert(argc >= 0); assert(argv); @@ -179,7 +169,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-network-generator"); OPTION_COMMON_VERSION: return version(); @@ -188,6 +178,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { "Operate on an alternate filesystem root"): arg_root = opts.arg; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } *ret_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 dea9fb713d..68391c9fcc 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -41,6 +41,7 @@ INTROSPECTABLE=( systemd-journal-upload systemd-modules-load systemd-mute-console + systemd-network-generator systemd-notify systemd-oomd systemd-path