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] 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