]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timedatectl: port to new 'vertical' table type 25328/head
authorLennart Poettering <lennart@poettering.net>
Thu, 10 Nov 2022 12:32:08 +0000 (13:32 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 10 Nov 2022 22:11:17 +0000 (23:11 +0100)
src/timedate/timedatectl.c

index e3c722610a2ca9081ed9f831bf2b9c5463d2daa4..5d1be1150940a1cc4dee7589e781cab13154bf47 100644 (file)
@@ -61,15 +61,12 @@ static int print_status_info(const StatusInfo *i) {
 
         assert(i);
 
-        table = table_new("key", "value");
+        table = table_new_vertical();
         if (!table)
                 return log_oom();
 
-        table_set_header(table, false);
-
         assert_se(cell = table_get_cell(table, 0, 0));
         (void) table_set_ellipsize_percent(table, cell, 100);
-        (void) table_set_align_percent(table, cell, 100);
 
         assert_se(cell = table_get_cell(table, 0, 1));
         (void) table_set_ellipsize_percent(table, cell, 100);
@@ -97,14 +94,14 @@ static int print_status_info(const StatusInfo *i) {
 
         n = have_time ? strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&sec, &tm)) : 0;
         r = table_add_many(table,
-                           TABLE_STRING, "Local time:",
+                           TABLE_FIELD, "Local time",
                            TABLE_STRING, n > 0 ? a : "n/a");
         if (r < 0)
                 return table_log_add_error(r);
 
         n = have_time ? strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S UTC", gmtime_r(&sec, &tm)) : 0;
         r = table_add_many(table,
-                           TABLE_STRING, "Universal time:",
+                           TABLE_FIELD, "Universal time",
                            TABLE_STRING, n > 0 ? a : "n/a");
         if (r < 0)
                 return table_log_add_error(r);
@@ -117,12 +114,12 @@ static int print_status_info(const StatusInfo *i) {
         } else
                 n = 0;
         r = table_add_many(table,
-                           TABLE_STRING, "RTC time:",
+                           TABLE_FIELD, "RTC time",
                            TABLE_STRING, n > 0 ? a : "n/a");
         if (r < 0)
                 return table_log_add_error(r);
 
-        r = table_add_cell(table, NULL, TABLE_STRING, "Time zone:");
+        r = table_add_cell(table, NULL, TABLE_FIELD, "Time zone");
         if (r < 0)
                 return table_log_add_error(r);
 
@@ -139,11 +136,11 @@ static int print_status_info(const StatusInfo *i) {
                 tzset();
 
         r = table_add_many(table,
-                           TABLE_STRING, "System clock synchronized:",
+                           TABLE_FIELD, "System clock synchronized",
                            TABLE_BOOLEAN, i->ntp_synced,
-                           TABLE_STRING, "NTP service:",
+                           TABLE_FIELD, "NTP service",
                            TABLE_STRING, i->ntp_capable ? (i->ntp_active ? "active" : "inactive") : "n/a",
-                           TABLE_STRING, "RTC in local TZ:",
+                           TABLE_FIELD, "RTC in local TZ",
                            TABLE_BOOLEAN, i->rtc_local);
         if (r < 0)
                 return table_log_add_error(r);
@@ -363,15 +360,12 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
 
         assert(i);
 
-        table = table_new("key", "value");
+        table = table_new_vertical();
         if (!table)
                 return log_oom();
 
-        table_set_header(table, false);
-
         assert_se(cell = table_get_cell(table, 0, 0));
         (void) table_set_ellipsize_percent(table, cell, 100);
-        (void) table_set_align_percent(table, cell, 100);
 
         assert_se(cell = table_get_cell(table, 0, 1));
         (void) table_set_ellipsize_percent(table, cell, 100);
@@ -388,7 +382,7 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
          *  d = (T4 - T1) - (T3 - T2)     t = ((T2 - T1) + (T3 - T4)) / 2"
          */
 
-        r = table_add_cell(table, NULL, TABLE_STRING, "Server:");
+        r = table_add_cell(table, NULL, TABLE_FIELD, "Server");
         if (r < 0)
                 return table_log_add_error(r);
 
@@ -396,7 +390,7 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
         if (r < 0)
                 return table_log_add_error(r);
 
-        r = table_add_cell(table, NULL, TABLE_STRING, "Poll interval:");
+        r = table_add_cell(table, NULL, TABLE_FIELD, "Poll interval");
         if (r < 0)
                 return table_log_add_error(r);
 
@@ -409,7 +403,7 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
 
         if (i->packet_count == 0) {
                 r = table_add_many(table,
-                                   TABLE_STRING, "Packet count:",
+                                   TABLE_FIELD, "Packet count",
                                    TABLE_STRING, "0");
                 if (r < 0)
                         return table_log_add_error(r);
@@ -440,13 +434,13 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
         root_distance = i->root_delay / 2 + i->root_dispersion;
 
         r = table_add_many(table,
-                           TABLE_STRING, "Leap:",
+                           TABLE_FIELD, "Leap",
                            TABLE_STRING, ntp_leap_to_string(i->leap),
-                           TABLE_STRING, "Version:",
+                           TABLE_FIELD, "Version",
                            TABLE_UINT32, i->version,
-                           TABLE_STRING, "Stratum:",
+                           TABLE_FIELD, "Stratum",
                            TABLE_UINT32, i->stratum,
-                           TABLE_STRING, "Reference:");
+                           TABLE_FIELD, "Reference");
         if (r < 0)
                 return table_log_add_error(r);
 
@@ -457,7 +451,7 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
         if (r < 0)
                 return table_log_add_error(r);
 
-        r = table_add_cell(table, NULL, TABLE_STRING, "Precision:");
+        r = table_add_cell(table, NULL, TABLE_FIELD, "Precision");
         if (r < 0)
                 return table_log_add_error(r);
 
@@ -467,7 +461,7 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
         if (r < 0)
                 return table_log_add_error(r);
 
-        r = table_add_cell(table, NULL, TABLE_STRING, "Root distance:");
+        r = table_add_cell(table, NULL, TABLE_FIELD, "Root distance");
         if (r < 0)
                 return table_log_add_error(r);
 
@@ -477,7 +471,7 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
         if (r < 0)
                 return table_log_add_error(r);
 
-        r = table_add_cell(table, NULL, TABLE_STRING, "Offset:");
+        r = table_add_cell(table, NULL, TABLE_FIELD, "Offset");
         if (r < 0)
                 return table_log_add_error(r);
 
@@ -488,17 +482,17 @@ static int print_ntp_status_info(NTPStatusInfo *i) {
                 return table_log_add_error(r);
 
         r = table_add_many(table,
-                           TABLE_STRING, "Delay:",
+                           TABLE_FIELD, "Delay",
                            TABLE_STRING, FORMAT_TIMESPAN(delay, 0),
-                           TABLE_STRING, "Jitter:",
+                           TABLE_FIELD, "Jitter",
                            TABLE_STRING, FORMAT_TIMESPAN(i->jitter, 0),
-                           TABLE_STRING, "Packet count:",
+                           TABLE_FIELD, "Packet count",
                            TABLE_UINT64, i->packet_count);
         if (r < 0)
                 return table_log_add_error(r);
 
         if (!i->spike) {
-                r = table_add_cell(table, NULL, TABLE_STRING, "Frequency:");
+                r = table_add_cell(table, NULL, TABLE_FIELD, "Frequency");
                 if (r < 0)
                         return table_log_add_error(r);