]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/verbs: display default verb as "[verb]"
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Tue, 5 May 2026 08:59:46 +0000 (10:59 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Tue, 5 May 2026 09:14:33 +0000 (11:14 +0200)
src/shared/verbs.c

index dfecf048612b79e083ab24827823a2b893a5a085..276c6fd5be91623e576db146f11b5cfd4f8844b4 100644 (file)
@@ -192,11 +192,15 @@ int _verbs_get_help_table(
                         /* No help string — we do not show the verb */
                         continue;
 
+                bool is_default = FLAGS_SET(verb->flags, VERB_DEFAULT);
+
                 /* We indent the option string by two spaces. We could set the minimum cell width and
                  * right-align for a similar result, but that'd be more work. This is only used for
                  * display. */
-                r = table_add_cell_stringf(table, NULL, "  %s%s%s",
+                r = table_add_cell_stringf(table, NULL, "  %s%s%s%s%s",
+                                           is_default ? "[" : "",
                                            verb->verb,
+                                           is_default ? "]" : "",
                                            verb->argspec ? " " : "",
                                            strempty(verb->argspec));
                 if (r < 0)