]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ac-power: update the help output to use the ansi-color functions
authorZIHCO <chizobajames21@gmail.com>
Wed, 26 Mar 2025 19:50:15 +0000 (20:50 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 27 Mar 2025 05:58:08 +0000 (14:58 +0900)
src/ac-power/ac-power.c

index af76b81de69b105e790fc4150247f45da7692bd9..e184bc443225d70fe410847b468077421588c3d2 100644 (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[]) {