ac-power: update the help output to use the ansi-color functions

This commit is contained in:
ZIHCO
2025-03-26 20:50:15 +01:00
committed by Yu Watanabe
parent e2c801e767
commit 72586a971b

View File

@@ -2,9 +2,11 @@
#include <getopt.h>
#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[]) {