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

The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The "Options" group marker after --help/--version
is dropped, so that all options are listed in one section after the verbs.
The synopsis now uses the generic "[OPTION…] COMMAND …" form: a bare
VERSION is not accepted as the first argument, and the man page does not
list it either. --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 388eb27018
commit adc83f020a
2 changed files with 13 additions and 46 deletions
+12 -46
View File
@@ -23,14 +23,12 @@
#include "format-table.h"
#include "glyph-util.h"
#include "hashmap.h"
#include "help-util.h"
#include "hexdecoct.h"
#include "image-policy.h"
#include "json-util.h"
#include "loop-util.h"
#include "main-func.h"
#include "mount-util.h"
#include "options.h"
#include "os-util.h"
#include "pager.h"
#include "parse-argument.h"
@@ -83,6 +81,13 @@ STATIC_DESTRUCTOR_REGISTER(arg_component, freep);
STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
STATIC_DESTRUCTOR_REGISTER(arg_transfer_source, freep);
COMMAND(
"systemd-sysupdate\0",
"Update OS images.",
.man_pages = "systemd-sysupdate.8\0",
.pager_flags = &arg_pager_flags,
);
#define CONTEXT_NULL \
(Context) { \
.component_enabled = true, \
@@ -3301,46 +3306,7 @@ static int verb_enable_component(int argc, char *argv[], uintptr_t _data, void *
return 0;
}
static int help(void) {
_cleanup_(table_unrefp) Table *common_options = NULL, *options = NULL, *verbs = NULL;
int r;
r = verbs_get_help_table(&verbs);
if (r < 0)
return r;
r = option_parser_get_help_table(&common_options);
if (r < 0)
return r;
r = option_parser_get_help_table_group("Options", &options);
if (r < 0)
return r;
(void) table_sync_column_widths(0, verbs, common_options, options);
help_cmdline("[OPTIONS…] [VERSION]");
help_abstract("Update OS images.");
help_section("Commands");
r = table_print_or_warn(verbs);
if (r < 0)
return r;
r = table_print_or_warn(common_options);
if (r < 0)
return r;
help_section("Options");
r = table_print_or_warn(options);
if (r < 0)
return r;
help_man_page_reference("systemd-sysupdate", "8");
return 0;
}
VERB_COMMON_HELP_HIDDEN(help);
VERB_COMMON_HELP_AUTO_HIDDEN("systemd-sysupdate");
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
assert(argc >= 0);
@@ -3354,14 +3320,11 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-sysupdate");
OPTION_COMMON_VERSION:
return version();
OPTION_GROUP("Options"):
break;
OPTION('C', "component", "NAME",
"Select component to update"):
if (isempty(opts.arg)) {
@@ -3496,6 +3459,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
return r;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(arg_json_format_flags);
}
if (arg_image && arg_root)
@@ -89,6 +89,7 @@ INTROSPECTABLE=(
systemd-storagetm
systemd-sysctl
systemd-sysinstall
systemd-sysupdate
systemd-tpm2-clear
systemd-tpm2-setup
systemd-tty-ask-password-agent