From 72586a971b5ee26b6681fc34ba43c0081dbd94da Mon Sep 17 00:00:00 2001 From: ZIHCO Date: Wed, 26 Mar 2025 20:50:15 +0100 Subject: [PATCH] ac-power: update the help output to use the ansi-color functions --- src/ac-power/ac-power.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/ac-power/ac-power.c b/src/ac-power/ac-power.c index af76b81de69..e184bc44322 100644 --- a/src/ac-power/ac-power.c +++ b/src/ac-power/ac-power.c @@ -2,9 +2,11 @@ #include +#include "ansi-color.h" #include "battery-util.h" #include "build.h" #include "main-func.h" +#include "pretty-print.h" static bool arg_verbose = false; @@ -13,14 +15,29 @@ static enum { ACTION_LOW, } arg_action = ACTION_AC_POWER; -static void help(void) { - printf("%s\n\n" - "Report whether we are connected to an external power source.\n\n" +static int help(void) { + _cleanup_free_ char *link = NULL; + int r; + + r = terminal_urlify_man("systemd-ac-power", "1", &link); + if (r < 0) + return log_oom(); + + printf("%1$s [OPTION]\n" + "\n%2$sReport whether we are connected to an external power source.%4$s\n" + "\n%3$sOptions:%4$s\n" " -h --help Show this help\n" " --version Show package version\n" " -v --verbose Show state as text\n" - " --low Check if battery is discharging and low\n", - program_invocation_short_name); + " --low Check if battery is discharging and low\n" + "\nSee the %3$s%5$s%4$s for details.\n", + program_invocation_short_name, + ansi_highlight(), + ansi_underline(), + ansi_normal(), + link); + + return 0; } static int parse_argv(int argc, char *argv[]) { -- 2.47.3