]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
imds: use help-util.h helpers for --help output 42409/head
authorLennart Poettering <lennart@amutable.com>
Sun, 31 May 2026 19:57:39 +0000 (21:57 +0200)
committerLennart Poettering <lennart@amutable.com>
Mon, 22 Jun 2026 20:03:12 +0000 (22:03 +0200)
Convert the --help text of systemd-imds and systemd-imdsd to the common
help_cmdline()/help_abstract()/help_section()/help_man_page_reference()
helpers, for a uniform output style across tools.

src/imds/imds-tool.c
src/imds/imdsd.c

index bc0a6b1103b0abf471d1cbf223523de98bb3033e..e46d335cca177a905bf1a071a157af2fbbb58e36 100644 (file)
@@ -17,6 +17,7 @@
 #include "format-table.h"
 #include "format-util.h"
 #include "fs-util.h"
+#include "help-util.h"
 #include "hexdecoct.h"
 #include "imds-tool.h"
 #include "imds-tool-metrics.h"
@@ -30,7 +31,6 @@
 #include "options.h"
 #include "parse-argument.h"
 #include "pcrextend-util.h"
-#include "pretty-print.h"
 #include "string-util.h"
 #include "strv.h"
 #include "time-util.h"
@@ -52,29 +52,22 @@ static bool arg_refresh_usec_set = false;
 STATIC_DESTRUCTOR_REGISTER(arg_key, freep);
 
 static int help(void) {
-        _cleanup_free_ char *link = NULL;
         _cleanup_(table_unrefp) Table *options = NULL;
         int r;
 
-        r = terminal_urlify_man("systemd-imds", "1", &link);
-        if (r < 0)
-                return log_oom();
-
         r = option_parser_get_help_table(&options);
         if (r < 0)
                 return r;
 
-        printf("%s [OPTIONS...] [KEY]\n"
-               "\n%sIMDS data acquisition.%s\n\n",
-               program_invocation_short_name,
-               ansi_highlight(),
-               ansi_normal());
+        help_cmdline("[OPTIONS...] [KEY]");
+        help_abstract("IMDS data acquisition.");
 
+        help_section("Options");
         r = table_print_or_warn(options);
         if (r < 0)
                 return r;
 
-        printf("\nSee the %s for details.\n", link);
+        help_man_page_reference("systemd-imds", "1");
         return 0;
 }
 
index 9959567f5f350e46299ffe66ada70b9e3aaa1424..ea079fdbd274721b729beb3f873e848a34a0bd49 100644 (file)
 #include "event-util.h"
 #include "exit-status.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "format-ifname.h"
 #include "format-table.h"
 #include "hash-funcs.h"
 #include "hashmap.h"
+#include "help-util.h"
 #include "imds-util.h"
 #include "in-addr-util.h"
 #include "io-util.h"
@@ -42,7 +44,6 @@
 #include "parse-argument.h"
 #include "parse-util.h"
 #include "path-util.h"
-#include "pretty-print.h"
 #include "proc-cmdline.h"
 #include "socket-util.h"
 #include "string-util.h"
@@ -2192,14 +2193,9 @@ static int vl_server(void) {
 }
 
 static int help(void) {
-        _cleanup_free_ char *link = NULL;
         _cleanup_(table_unrefp) Table *options = NULL, *endpoint_options = NULL;
         int r;
 
-        r = terminal_urlify_man("systemd-imdsd@.service", "8", &link);
-        if (r < 0)
-                return log_oom();
-
         r = option_parser_get_help_table(&options);
         if (r < 0)
                 return r;
@@ -2210,28 +2206,20 @@ static int help(void) {
 
         (void) table_sync_column_widths(0, options, endpoint_options);
 
-        printf("%1$s [OPTIONS...] KEY\n"
-               "\n%2$sLow-level IMDS data acquisition.%3$s\n"
-               "\n%4$sOptions:%5$s\n",
-               program_invocation_short_name,
-               ansi_highlight(),
-               ansi_normal(),
-               ansi_underline(),
-               ansi_normal());
+        help_cmdline("[OPTIONS...] KEY");
+        help_abstract("Low-level IMDS data acquisition.");
 
+        help_section("Options");
         r = table_print_or_warn(options);
         if (r < 0)
                 return r;
 
-        printf("\n%sManual Endpoint Configuration:%s\n",
-               ansi_underline(),
-               ansi_normal());
-
+        help_section("Manual Endpoint Configuration");
         r = table_print_or_warn(endpoint_options);
         if (r < 0)
                 return r;
 
-        printf("\nSee the %s for details.\n", link);
+        help_man_page_reference("systemd-imdsd@.service", "8");
         return 0;
 }