repart: convert to VERB_COMMAND and add --introspect-cli

The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. --help now goes through the pager, like other
commands with --no-pager.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-18 16:54:09 +02:00
parent 19a24f926d
commit be5ae9fb40
2 changed files with 14 additions and 58 deletions
+13 -58
View File
@@ -61,7 +61,6 @@
#include "mount-util.h"
#include "mountpoint-util.h"
#include "nulstr-util.h"
#include "options.h"
#include "parse-argument.h"
#include "parse-helpers.h"
#include "parse-util.h"
@@ -88,6 +87,7 @@
#include "utf8.h"
#include "varlink-io.systemd.Repart.h"
#include "varlink-util.h"
#include "verbs.h"
#include "xattr-util.h"
/* If not configured otherwise use a minimal partition size of 10M */
@@ -248,6 +248,14 @@ STATIC_DESTRUCTOR_REGISTER(arg_eltorito_system, freep);
STATIC_DESTRUCTOR_REGISTER(arg_eltorito_volume, freep);
STATIC_DESTRUCTOR_REGISTER(arg_eltorito_publisher, freep);
COMMAND(
"systemd-repart\0",
"Grow and add partitions to a partition table, and generate disk images (DDIs).",
.argspec = "[DEVICE]\0",
.man_pages = "systemd-repart.8\0",
.pager_flags = &arg_pager_flags,
);
typedef enum ProgressPhase {
PROGRESS_LOADING_DEFINITIONS,
PROGRESS_LOADING_TABLE,
@@ -10167,62 +10175,6 @@ static int parse_join_signature(const char *p, Set **verity_settings_map) {
return 0;
}
static int help(void) {
_cleanup_free_ char *link = NULL;
int r;
r = terminal_urlify_man("systemd-repart", "8", &link);
if (r < 0)
return log_oom();
static const char *const option_groups[] = {
"Options",
"Operation",
"Output",
"Factory Reset",
"Configuration & Image Control",
"Verity",
"Encryption",
"Partition Control",
"Copying",
"DDI Profile",
"Auxiliary Resource Generation",
"El Torito boot catalog",
};
Table *option_tables[ELEMENTSOF(option_groups)] = {};
CLEANUP_ELEMENTS(option_tables, table_unref_array_clear);
for (size_t i = 0; i < ELEMENTSOF(option_groups); i++) {
r = option_parser_get_help_table_group(option_groups[i], &option_tables[i]);
if (r < 0)
return r;
}
(void) table_sync_column_widths(0,
option_tables[0], option_tables[1], option_tables[2],
option_tables[3], option_tables[4], option_tables[5],
option_tables[6], option_tables[7], option_tables[8],
option_tables[9], option_tables[10], option_tables[11]);
printf("%s [OPTIONS...] [DEVICE]\n"
"\n%sGrow and add partitions to a partition table, and generate disk images (DDIs).%s\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
for (size_t i = 0; i < ELEMENTSOF(option_groups); i++) {
printf("\n%s%s:%s\n", ansi_underline(), option_groups[i], ansi_normal());
r = table_print_or_warn(option_tables[i]);
if (r < 0)
return r;
}
printf("\nSee the %s for details.\n", link);
return 0;
}
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
@@ -10237,7 +10189,7 @@ static int parse_argv(int argc, char *argv[]) {
OPTION_GROUP("Options"): {}
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-repart");
OPTION_COMMON_VERSION:
return version();
@@ -10765,6 +10717,9 @@ static int parse_argv(int argc, char *argv[]) {
return r;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(arg_json_format_flags);
}
if (option_parser_get_n_args(&opts) > 1)
@@ -73,6 +73,7 @@ INTROSPECTABLE=(
systemd-pcrlock
systemd-pty-forward
systemd-random-seed
systemd-repart
systemd-report
systemd-sbsign
systemd-sleep