diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index 85452f62a5..9ae6531472 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -6,6 +6,8 @@ #include #include +#include "sd-json.h" + #include "alloc-util.h" #include "assert.h" #include "build.h" @@ -16,18 +18,16 @@ #include "errno-util.h" #include "fd-util.h" #include "fileio.h" -#include "format-table.h" #include "log.h" #include "macro.h" #include "main-func.h" #include "module-util.h" -#include "options.h" #include "ordered-set.h" #include "parse-util.h" -#include "pretty-print.h" #include "proc-cmdline.h" #include "string-util.h" #include "strv.h" +#include "verbs.h" #define MODULE_NAME_MAX_LEN (4096UL) @@ -36,6 +36,13 @@ static const char conf_file_dirs[] = CONF_PATHS_NULSTR("modules-load.d"); STATIC_DESTRUCTOR_REGISTER(arg_proc_cmdline_modules, strv_freep); +COMMAND( + "systemd-modules-load\0", + "Load statically configured kernel modules.", + .argspec = "[CONFIGURATION FILE…]\0", + .man_pages = "systemd-modules-load.service.8\0", +); + static int modules_list_append_suffix(OrderedSet **module_set, char *modp) { /* take possession of string no matter what */ _cleanup_free_ char *mod = modp; @@ -332,30 +339,6 @@ static unsigned determine_num_worker_threads(unsigned n_modules) { return n_threads - 1U; } -static int help(void) { - _cleanup_free_ char *link = NULL; - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - if (terminal_urlify_man("systemd-modules-load.service", "8", &link) < 0) - return log_oom(); - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - printf("%s [OPTIONS...] [CONFIGURATION FILE...]\n\n" - "Loads statically configured kernel modules.\n\n", - program_invocation_short_name); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - printf("\nSee the %s for details.\n", link); - return 0; -} - static int parse_argv(int argc, char *argv[], char ***ret_args) { assert(argc >= 0); assert(argv); @@ -367,10 +350,13 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-modules-load"); OPTION_COMMON_VERSION: return version(); + + 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 55f95fa1a4..dea9fb713d 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -39,6 +39,7 @@ INTROSPECTABLE=( systemd-journal-gatewayd systemd-journal-remote systemd-journal-upload + systemd-modules-load systemd-mute-console systemd-notify systemd-oomd