shared/verbs: turn verb argument specification into nulstr

Like the command-level CommandDescription.argspec, a verb's argspec is now
a nulstr, so that a verb may declare multiple alternative usage lines. The
verbs help table renders one synopsis line per nulstr entry in the
synopsis cell.

All verb argument specifications must gain an explicit NUL suffix. This
is a lot of churn, but I think this needs to be done. For now, there'll
be only one user of the new functionality (i.e. a verb with more than
one argspec), but I think we'll eventually want to use this in other
places too.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-28 09:29:04 +02:00
parent 057fc4251a
commit efd63ddfbf
42 changed files with 365 additions and 351 deletions
+8 -8
View File
@@ -1942,7 +1942,7 @@ static int verify_polkit(Context *context, sd_varlink *link, const char *action,
&s->polkit_registry);
}
VERB(verb_list, "list", "[VERSION]", VERB_ANY, 2, VERB_DEFAULT,
VERB(verb_list, "list", "[VERSION]\0", VERB_ANY, 2, VERB_DEFAULT,
"Show installed and available versions");
static int verb_list(int argc, char *argv[], uintptr_t _data, void *userdata) {
_cleanup_(context_done) Context context = CONTEXT_NULL;
@@ -2019,7 +2019,7 @@ static int verb_list(int argc, char *argv[], uintptr_t _data, void *userdata) {
}
}
VERB(verb_features, "features", "[FEATURE]", VERB_ANY, 2, 0,
VERB(verb_features, "features", "[FEATURE]\0", VERB_ANY, 2, 0,
"Show optional features");
static int verb_features(int argc, char *argv[], uintptr_t _data, void *userdata) {
_cleanup_(context_done) Context context = CONTEXT_NULL;
@@ -2312,9 +2312,9 @@ static int context_enable_feature(
return ret;
}
VERB(verb_enable_feature, "enable-feature", "FEATURE…", 1, VERB_ANY, 0,
VERB(verb_enable_feature, "enable-feature", "FEATURE…\0", 1, VERB_ANY, 0,
"Enable optional feature");
VERB(verb_enable_feature, "disable-feature", "FEATURE…", 1, VERB_ANY, 0,
VERB(verb_enable_feature, "disable-feature", "FEATURE…\0", 1, VERB_ANY, 0,
"Disable optional feature");
static int verb_enable_feature(int argc, char *argv[], uintptr_t _data, void *userdata) {
bool enable = streq(argv[0], "enable-feature");
@@ -2759,7 +2759,7 @@ static int verb_update_impl(int argc, char **argv, UpdateActionFlags action_flag
}
}
VERB(verb_update, "update", "[VERSION]", VERB_ANY, 2, 0,
VERB(verb_update, "update", "[VERSION]\0", VERB_ANY, 2, 0,
"Install new version now");
static int verb_update(int argc, char *argv[], uintptr_t _data, void *userdata) {
UpdateActionFlags flags = UPDATE_ACTION_INSTALL;
@@ -2770,7 +2770,7 @@ static int verb_update(int argc, char *argv[], uintptr_t _data, void *userdata)
return verb_update_impl(argc, argv, flags);
}
VERB(verb_acquire, "acquire", "[VERSION]", VERB_ANY, 2, 0,
VERB(verb_acquire, "acquire", "[VERSION]\0", VERB_ANY, 2, 0,
"Acquire (download) new version now");
static int verb_acquire(int argc, char *argv[], uintptr_t _data, void *userdata) {
return verb_update_impl(argc, argv, UPDATE_ACTION_ACQUIRE);
@@ -3163,9 +3163,9 @@ static int vl_method_list_targets(sd_varlink *link, sd_json_variant *parameters,
SD_JSON_BUILD_PAIR_VARIANT("targets", l));
}
VERB(verb_enable_component, "enable-component", "COMPONENT…", 1, VERB_ANY, 0,
VERB(verb_enable_component, "enable-component", "COMPONENT…\0", 1, VERB_ANY, 0,
"Enable component");
VERB(verb_enable_component, "disable-component", "COMPONENT…", 1, VERB_ANY, 0,
VERB(verb_enable_component, "disable-component", "COMPONENT…\0", 1, VERB_ANY, 0,
"Disable component");
static int verb_enable_component(int argc, char *argv[], uintptr_t _data, void *userdata) {
bool enable = streq(argv[0], "enable-component");
+7 -7
View File
@@ -651,7 +651,7 @@ static int describe(sd_bus *bus, const char *target_path, const char *version) {
return table_print_with_pager(table, SD_JSON_FORMAT_OFF, arg_pager_flags, arg_legend);
}
VERB(verb_list, "list", "[TARGET[@VERSION]]", VERB_ANY, 2, VERB_DEFAULT|VERB_ONLINE_ONLY,
VERB(verb_list, "list", "[TARGET[@VERSION]]\0", VERB_ANY, 2, VERB_DEFAULT|VERB_ONLINE_ONLY,
"List available targets and versions");
static int verb_list(int argc, char *argv[], uintptr_t _data, void *userdata) {
sd_bus *bus = ASSERT_PTR(userdata);
@@ -764,7 +764,7 @@ static int check_finished(sd_bus_message *reply, void *userdata, sd_bus_error *r
return 0;
}
VERB(verb_check, "check", "[TARGET...]", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY,
VERB(verb_check, "check", "[TARGET...]\0", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY,
"Check for updates");
static int verb_check(int argc, char *argv[], uintptr_t _data, void *userdata) {
sd_bus *bus = ASSERT_PTR(userdata);
@@ -1306,7 +1306,7 @@ static int do_update(sd_bus *bus, char **targets) {
return did_anything ? 1 : 0;
}
VERB(verb_update, "update", "[TARGET[@VERSION]...]", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY,
VERB(verb_update, "update", "[TARGET[@VERSION]...]\0", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY,
"Install updates");
static int verb_update(int argc, char *argv[], uintptr_t _data, void *userdata) {
sd_bus *bus = ASSERT_PTR(userdata);
@@ -1361,7 +1361,7 @@ static int do_vacuum(sd_bus *bus, const char *target, const char *path) {
return count + disabled > 0 ? 1 : 0;
}
VERB(verb_vacuum, "vacuum", "[TARGET...]", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY,
VERB(verb_vacuum, "vacuum", "[TARGET...]\0", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY,
"Clean up old updates");
static int verb_vacuum(int argc, char *argv[], uintptr_t _data, void *userdata) {
sd_bus *bus = ASSERT_PTR(userdata);
@@ -1507,7 +1507,7 @@ static int list_features(sd_bus *bus) {
return table_print_with_pager(table, SD_JSON_FORMAT_OFF, arg_pager_flags, arg_legend);
}
VERB(verb_features, "features", "[FEATURE]", VERB_ANY, 2, VERB_ONLINE_ONLY,
VERB(verb_features, "features", "[FEATURE]\0", VERB_ANY, 2, VERB_ONLINE_ONLY,
"List and inspect optional features on host OS");
static int verb_features(int argc, char *argv[], uintptr_t _data, void *userdata) {
sd_bus *bus = ASSERT_PTR(userdata);
@@ -1558,9 +1558,9 @@ static int verb_features(int argc, char *argv[], uintptr_t _data, void *userdata
return table_print_with_pager(table, SD_JSON_FORMAT_OFF, arg_pager_flags, false);
}
VERB(verb_enable, "enable", "FEATURE...", 2, VERB_ANY, VERB_ONLINE_ONLY,
VERB(verb_enable, "enable", "FEATURE...\0", 2, VERB_ANY, VERB_ONLINE_ONLY,
"Enable optional feature on host OS");
VERB(verb_enable, "disable", "FEATURE...", 2, VERB_ANY, VERB_ONLINE_ONLY,
VERB(verb_enable, "disable", "FEATURE...\0", 2, VERB_ANY, VERB_ONLINE_ONLY,
"Disable optional feature on host OS");
static int verb_enable(int argc, char *argv[], uintptr_t _data, void *userdata) {
sd_bus *bus = ASSERT_PTR(userdata);