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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-19 08:21:29 +02:00
parent 3e61b718a5
commit 9832927a08
2 changed files with 13 additions and 43 deletions
+12 -43
View File
@@ -3,15 +3,15 @@
#include <locale.h>
#include <unistd.h>
#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) {
@@ -64,6 +64,7 @@ INTROSPECTABLE=(
systemd-imds
systemd-imdsd
systemd-import
systemd-import-fs
systemd-inhibit
systemd-journal-gatewayd
systemd-journal-remote