]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Table formatter now hides the titles if all of them are marked hidden.
authorTimo Sirainen <tss@iki.fi>
Sun, 24 Mar 2013 16:13:53 +0000 (18:13 +0200)
committerTimo Sirainen <tss@iki.fi>
Sun, 24 Mar 2013 16:13:53 +0000 (18:13 +0200)
src/doveadm/doveadm-print-table.c

index 7a86571d160316947153393caf6bd22c37deb5ba..168167dfe09008169f56703659fc0b2e36ac8474 100644 (file)
@@ -135,16 +135,20 @@ static void doveadm_print_next(const char *value)
        }
 }
 
-static void doveadm_buffer_flush(void)
+static void doveadm_print_headers(void)
 {
        const struct doveadm_print_table_header *headers;
-       const char *const *valuep;
        unsigned int i, count;
 
-       doveadm_calc_header_length();
-
        headers = array_get(&ctx->headers, &count);
+       /* if all headers are hidden, don't print any of them */
        for (i = 0; i < count; i++) {
+               if ((headers[i].flags & DOVEADM_PRINT_HEADER_FLAG_HIDE_TITLE) == 0)
+                       break;
+       }
+       if (i == count)
+               return;
+       for (; i < count; i++) {
                if (i > 0) fprintf(stderr, " ");
 
                if ((headers[i].flags &
@@ -157,6 +161,14 @@ static void doveadm_buffer_flush(void)
                }
        }
        fprintf(stderr, "\n");
+}
+
+static void doveadm_buffer_flush(void)
+{
+       const char *const *valuep;
+
+       doveadm_calc_header_length();
+       doveadm_print_headers();
 
        array_foreach(&ctx->buffered_values, valuep)
                doveadm_print_next(*valuep);