From: Lennart Poettering Date: Sun, 31 May 2026 19:57:39 +0000 (+0200) Subject: imds: use help-util.h helpers for --help output X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d0f4ff915831617292a512edcd0d4ef6361a854;p=thirdparty%2Fsystemd.git imds: use help-util.h helpers for --help output 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. --- diff --git a/src/imds/imds-tool.c b/src/imds/imds-tool.c index bc0a6b1103b..e46d335cca1 100644 --- a/src/imds/imds-tool.c +++ b/src/imds/imds-tool.c @@ -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; } diff --git a/src/imds/imdsd.c b/src/imds/imdsd.c index 9959567f5f3..ea079fdbd27 100644 --- a/src/imds/imdsd.c +++ b/src/imds/imdsd.c @@ -26,10 +26,12 @@ #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; }