shared/verbs: add command_print_verb_help()

A helper to print the help of a single verb, derived entirely from the
data in the SYSTEMD_VERBS and SYSTEMD_OPTIONS sections: the synopsis is
built from the verb name and argspec, the one-line verb help serves as
the abstract, the options come from the verb's option namespace, and the
man page links from the command the verb belongs to. A flag allows
suppressing the man page links for callers which append custom sections.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-28 09:29:04 +02:00
parent efd63ddfbf
commit 3cfe456323
3 changed files with 93 additions and 0 deletions
+9
View File
@@ -114,4 +114,13 @@ TEST(introspect_cli_verb_options) {
SD_JSON_FORMAT_OFF));
}
TEST(command_print_verb_help) {
ASSERT_OK(_command_print_verb_help(introspect_verbs, introspect_verbs + ELEMENTSOF(introspect_verbs) - 1,
introspect_options, introspect_options + ELEMENTSOF(introspect_options) - 1,
"alpha"));
ASSERT_OK(_command_print_verb_help(introspect_verbs, introspect_verbs + ELEMENTSOF(introspect_verbs) - 1,
introspect_options, introspect_options + ELEMENTSOF(introspect_options) - 1,
"beta"));
}
DEFINE_TEST_MAIN(LOG_INFO);