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

This converts systemd-homed, -hostnamed, -importd, -localed, -logind,
-machined, -networkd, -portebled, -resolved, -sysupdated, -timedated,
and -timesyncd.

The service name and description move from service_parse_argv() arguments
into a COMMAND() description that each daemon now defines. The
service_parse_argv() macro captures the calling binary's verb section,
where that COMMAND is found, while the options are still defined and
parsed in libshared, in the new "service" option namespace that each
COMMAND references. (The named namespace makes sure that options defined
by other translation units in libshared can never leak into the
services' parsers.)

The supported features are declared via option group filtering: each
COMMAND lists "Options" plus "Bus introspection" and/or "Runtime scope".
Unsupported options are now rejected by the parser as unknown options
(and are not shown in --help), replacing the runtime "This service does
not support …" errors.

The help output changes slightly: the "Bus introspection" and "Runtime
scope" option groups now get their own headings, and some descriptions
were reworded to the imperative form used elsewhere.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-26 12:15:25 +02:00
parent ed595e6b67
commit 65510d4cba
15 changed files with 220 additions and 102 deletions
+12 -3
View File
@@ -19,6 +19,17 @@
#include "service-util.h"
#include "strv.h"
#include "user-util.h"
#include "verbs.h"
COMMAND(
"systemd-networkd\0",
"Manage and configure network devices, create virtual network devices.",
.man_pages = "systemd-networkd.service.8\0",
.option_namespace = "service",
.option_groups =
"Options\0"
"Bus introspection\0",
);
static int run(int argc, char *argv[]) {
_cleanup_(manager_freep) Manager *m = NULL;
@@ -31,9 +42,7 @@ static int run(int argc, char *argv[]) {
log_setup();
r = service_parse_argv("systemd-networkd.service",
"Manage and configure network devices, create virtual network devices",
BUS_IMPLEMENTATIONS(&manager_object, &log_control_object),
r = service_parse_argv(BUS_IMPLEMENTATIONS(&manager_object, &log_control_object),
/* runtime_scope= */ NULL,
argc, argv);
if (r <= 0)