]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolvectl: color "comment" output grey
authorLennart Poettering <lennart@poettering.net>
Wed, 5 Dec 2018 17:38:50 +0000 (18:38 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 5 Dec 2018 17:46:23 +0000 (18:46 +0100)
Let's de-emphasize the "comment" output a bit, by making it grey.

src/basic/terminal-util.h
src/resolve/resolvectl.c

index 86e730028e4c1b7769cc0cf9e587f99d0d02bebe..c885e0a2d1a014dea069f46cf5e5e1d1537999e4 100644 (file)
@@ -18,6 +18,7 @@
 #define ANSI_MAGENTA "\x1B[0;35m"
 #define ANSI_CYAN    "\x1B[0;36m"
 #define ANSI_WHITE   "\x1B[0;37m"
+#define ANSI_GREY    "\x1B[0;2;37m"
 
 /* Bold/highlighted */
 #define ANSI_HIGHLIGHT_BLACK   "\x1B[0;1;30m"
@@ -132,6 +133,7 @@ DEFINE_ANSI_FUNC(highlight_yellow,           HIGHLIGHT_YELLOW);
 DEFINE_ANSI_FUNC(highlight_blue,             HIGHLIGHT_BLUE);
 DEFINE_ANSI_FUNC(highlight_magenta,          HIGHLIGHT_MAGENTA);
 DEFINE_ANSI_FUNC(normal,                     NORMAL);
+DEFINE_ANSI_FUNC(grey,                       GREY);
 
 DEFINE_ANSI_FUNC_UNDERLINE(underline,                  UNDERLINE, NORMAL);
 DEFINE_ANSI_FUNC_UNDERLINE(highlight_underline,        HIGHLIGHT_UNDERLINE, HIGHLIGHT);
index b7544741916031894592e9fadb2ede7198b3be9f..64abc3c46e8344b61ab4e1667178cd721400a760 100644 (file)
@@ -137,7 +137,7 @@ static void print_source(uint64_t flags, usec_t rtt) {
         if (flags == 0)
                 return;
 
-        fputs("\n-- Information acquired via", stdout);
+        printf("\n%s-- Information acquired via", ansi_grey());
 
         if (flags != 0)
                 printf(" protocol%s%s%s%s%s",
@@ -149,12 +149,10 @@ static void print_source(uint64_t flags, usec_t rtt) {
 
         assert_se(format_timespan(rtt_str, sizeof(rtt_str), rtt, 100));
 
-        printf(" in %s", rtt_str);
-
-        fputc('.', stdout);
-        fputc('\n', stdout);
-
-        printf("-- Data is authenticated: %s\n", yes_no(flags & SD_RESOLVED_AUTHENTICATED));
+        printf(" in %s.%s\n"
+               "%s-- Data is authenticated: %s%s\n",
+               rtt_str, ansi_normal(),
+               ansi_grey(), yes_no(flags & SD_RESOLVED_AUTHENTICATED), ansi_normal());
 }
 
 static void print_ifindex_comment(int printed_so_far, int ifindex) {
@@ -166,9 +164,9 @@ static void print_ifindex_comment(int printed_so_far, int ifindex) {
         if (!if_indextoname(ifindex, ifname))
                 log_warning_errno(errno, "Failed to resolve interface name for index %i, ignoring: %m", ifindex);
         else
-                printf("%*s-- link: %s",
+                printf("%*s%s-- link: %s%s",
                        60 > printed_so_far ? 60 - printed_so_far : 0, " ", /* Align comment to the 60th column */
-                       ifname);
+                       ansi_grey(), ifname, ansi_normal());
 }
 
 static int resolve_host(sd_bus *bus, const char *name) {