shared/verbs: allow commands to filter option groups

So far, option groups were only used for display: when parsing options,
the group markers were ignored and all options within a namespace were
considered as potential matches. The group was reported in introspection
data and used as section seperator in help display. To allow a single
option namespace to be used for two commands, pipe through a nulstr with
option group names to look at when parsing options. The field is set in
the Command description and used in various option-handling contexts:
- when parsing and looking for an option, do not consider the entries
  that are in the group that is not listed in the nulstr,
- when listing options in help or introspection, skip over unlisted
  groups.

The verbs_find_verb and verbs_find_command helpers are adjusted to have
a consistent interface.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-25 09:33:59 +02:00
parent dfe557dc7c
commit 5f45122e75
5 changed files with 99 additions and 33 deletions
+1 -2
View File
@@ -1093,8 +1093,7 @@ VERB_SCOPE(, verb_start, "condrestart", NULL, 2, VERB_ANY,
VERB_SCOPE(, verb_is_active, "check", NULL, 2, VERB_ANY, VERB_ONLINE_ONLY, /* help= */ NULL); /* deprecated alias of is-active */
int systemctl_main(char **args) {
assert((uintptr_t) __start_SYSTEMD_VERBS % sizeof(void*) == 0);
const Verb *verb = verbs_find_verb(args[0], __start_SYSTEMD_VERBS, __stop_SYSTEMD_VERBS);
const Verb *verb = verbs_find_verb(args[0]);
if (verb && (verb->flags & VERB_ONLINE_ONLY) && arg_root)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),