dovecot-2.2: doveadm: Added -h parameter to hide header line fro...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Mar 20 18:47:54 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/b84f4b881b88
changeset: 18377:b84f4b881b88
user: Timo Sirainen <tss at iki.fi>
date: Fri Mar 20 20:46:52 2015 +0200
description:
doveadm: Added -h parameter to hide header line from tab and table formatter output.
diffstat:
src/doveadm/doveadm-print-tab.c | 27 ++++++++++++++-------------
src/doveadm/doveadm-print-table.c | 3 +++
src/doveadm/doveadm-print.c | 2 ++
src/doveadm/doveadm-print.h | 1 +
src/doveadm/doveadm.c | 5 ++++-
5 files changed, 24 insertions(+), 14 deletions(-)
diffs (118 lines):
diff -r ef1a64509d68 -r b84f4b881b88 src/doveadm/doveadm-print-tab.c
--- a/src/doveadm/doveadm-print-tab.c Fri Mar 20 13:27:00 2015 +0200
+++ b/src/doveadm/doveadm-print-tab.c Fri Mar 20 20:46:52 2015 +0200
@@ -14,20 +14,27 @@
static struct doveadm_print_tab_context ctx;
+static void doveadm_print_tab_flush_header(void)
+{
+ if (!ctx.header_written) {
+ if (!doveadm_print_hide_titles)
+ printf("\n");
+ ctx.header_written = TRUE;
+ }
+}
+
static void
doveadm_print_tab_header(const struct doveadm_print_header *hdr)
{
if (ctx.header_count++ > 0)
printf("\t");
- printf("%s", hdr->title);
+ if (!doveadm_print_hide_titles)
+ printf("%s", hdr->title);
}
static void doveadm_print_tab_print(const char *value)
{
- if (!ctx.header_written) {
- printf("\n");
- ctx.header_written = TRUE;
- }
+ doveadm_print_tab_flush_header();
if (ctx.header_idx > 0)
printf("\t");
printf("%s", value);
@@ -45,10 +52,7 @@
doveadm_print_tab_print("");
return;
}
- if (!ctx.header_written) {
- printf("\n");
- ctx.header_written = TRUE;
- }
+ doveadm_print_tab_flush_header();
if (ctx.header_idx > 0)
printf("\t");
fwrite(value, 1, size, stdout);
@@ -56,10 +60,7 @@
static void doveadm_print_tab_flush(void)
{
- if (!ctx.header_written) {
- printf("\n");
- ctx.header_written = TRUE;
- }
+ doveadm_print_tab_flush_header();
}
struct doveadm_print_vfuncs doveadm_print_tab_vfuncs = {
diff -r ef1a64509d68 -r b84f4b881b88 src/doveadm/doveadm-print-table.c
--- a/src/doveadm/doveadm-print-table.c Fri Mar 20 13:27:00 2015 +0200
+++ b/src/doveadm/doveadm-print-table.c Fri Mar 20 20:46:52 2015 +0200
@@ -154,6 +154,9 @@
const struct doveadm_print_table_header *headers;
unsigned int i, count;
+ if (doveadm_print_hide_titles)
+ return;
+
headers = array_get(&ctx->headers, &count);
/* if all headers are hidden, don't print any of them */
for (i = 0; i < count; i++) {
diff -r ef1a64509d68 -r b84f4b881b88 src/doveadm/doveadm-print.c
--- a/src/doveadm/doveadm-print.c Fri Mar 20 13:27:00 2015 +0200
+++ b/src/doveadm/doveadm-print.c Fri Mar 20 20:46:52 2015 +0200
@@ -22,6 +22,8 @@
bool print_stream_open;
};
+bool doveadm_print_hide_titles = FALSE;
+
static struct doveadm_print_context *ctx;
bool doveadm_print_is_initialized(void)
diff -r ef1a64509d68 -r b84f4b881b88 src/doveadm/doveadm-print.h
--- a/src/doveadm/doveadm-print.h Fri Mar 20 13:27:00 2015 +0200
+++ b/src/doveadm/doveadm-print.h Fri Mar 20 20:46:52 2015 +0200
@@ -13,6 +13,7 @@
};
extern const struct doveadm_print_vfuncs *doveadm_print_vfuncs_all[];
+extern bool doveadm_print_hide_titles;
bool doveadm_print_is_initialized(void);
diff -r ef1a64509d68 -r b84f4b881b88 src/doveadm/doveadm.c
--- a/src/doveadm/doveadm.c Fri Mar 20 13:27:00 2015 +0200
+++ b/src/doveadm/doveadm.c Fri Mar 20 20:46:52 2015 +0200
@@ -271,7 +271,7 @@
/* "+" is GNU extension to stop at the first non-option.
others just accept -+ option. */
master_service = master_service_init("doveadm", service_flags,
- &argc, &argv, "+Df:v");
+ &argc, &argv, "+Df:hv");
while ((c = master_getopt(master_service)) > 0) {
switch (c) {
case 'D':
@@ -281,6 +281,9 @@
case 'f':
doveadm_print_init(optarg);
break;
+ case 'h':
+ doveadm_print_hide_titles = TRUE;
+ break;
case 'v':
doveadm_verbose = TRUE;
break;
More information about the dovecot-cvs
mailing list