From 94af9a8b4065edf47e80dcd78c2ce13cd1ef2e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 13 Aug 2026 13:52:35 +0200 Subject: [PATCH] verbs: wrap abstract too So far there's only one multi-line abstract. But as pointed out in the review, it's silly to handle footer but not the abstract. help_abstract() is not reused because it only works with one-line abstracts. (It always prints an empty line to separate paragraphs.) So the formatting is done anew in print_wrapped(). I think this is OK, since it's all very simple. After everything has been converted to COMMAND() and its helpers, help_abstract() and the sister functions will become unused and can be dropped then. --- src/resolve/resolvectl.c | 2 +- src/shared/verbs.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index 4336c4f90b..db69e1bbdf 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -97,7 +97,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_set_nta, strv_freep); COMMAND( "resolvectl\0", - "Send control commands to the network name resolution manager, or\n" + "Send control commands to the network name resolution manager, or " "resolve domain names, IPv4 and IPv6 addresses, DNS records, and services.", .man_pages = "resolvectl.1\0", .option_namespace = "resolvectl", diff --git a/src/shared/verbs.c b/src/shared/verbs.c index 66dc3e4994..0b27f4850c 100644 --- a/src/shared/verbs.c +++ b/src/shared/verbs.c @@ -431,7 +431,7 @@ static bool verbs_array_has_verbs(const Verb verbs[], const Verb verbs_end[]) { return false; } -static int print_wrapped(const char *text) { +static int print_wrapped(const char *text, bool abstract) { /* Print the text wrapped at spaces to the specified width. Newlines embedded in the text * are preserved and each line is wrapped independently, so explicit line breaks (e.g. @@ -457,7 +457,14 @@ static int print_wrapped(const char *text) { putchar('\n'); STRV_FOREACH(line, lines2) - puts(*line); + if (abstract) + printf("%s%s%s%s\n", + ansi_highlight(), + ansi_add_italics(), + *line, + ansi_normal()); + else + puts(*line); return 0; } @@ -492,14 +499,15 @@ int _command_print_help( help_cmdline(have_verbs ? "[OPTION…] COMMAND …" : "[OPTION…]"); } - if (cmd->abstract) - help_abstract(cmd->abstract); + r = print_wrapped(cmd->abstract, /* abstract= */ true); + if (r < 0) + return r; r = print_verb_option_help(cmd, cmdverb + 1, verbs_end, options, options_end); if (r < 0) return log_error_errno(r, "Failed to print verb&option help: %m"); - r = print_wrapped(cmd->footer); + r = print_wrapped(cmd->footer, /* abstract= */ false); if (r < 0) return r;