diff --git a/HISTORY b/HISTORY
index 395b60fb..2465de84 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,5 +1,6 @@
4.3 2019-??
repmgr: add --version-number command line option (Ian)
+ repmgr: add --terse option to "cluster show"; GitHub #521 (Ian)
repmgrd: check binary and extension major versions match; GitHub #515 (Ian)
4.2.1 2018-??-??
diff --git a/doc/appendix-release-notes.sgml b/doc/appendix-release-notes.sgml
index 10e90e2b..f674eb09 100644
--- a/doc/appendix-release-notes.sgml
+++ b/doc/appendix-release-notes.sgml
@@ -26,6 +26,15 @@
+
+
+ Add to repmgr cluster show (GitHub #521).
+
+
+ This makes it easier to copy the output into emails, chats etc. as a compact table.
+
+
+
repmgr --version-number outputs the "raw"
@@ -34,6 +43,7 @@
of the &repmgr; version.
+
diff --git a/doc/repmgr-cluster-show.sgml b/doc/repmgr-cluster-show.sgml
index 944d866c..94e52d10 100644
--- a/doc/repmgr-cluster-show.sgml
+++ b/doc/repmgr-cluster-show.sgml
@@ -120,6 +120,15 @@
+
+
+
+
+ Suppress display of the conninfo column.
+
+
+
+
diff --git a/repmgr-action-cluster.c b/repmgr-action-cluster.c
index 54919721..ab229423 100644
--- a/repmgr-action-cluster.c
+++ b/repmgr-action-cluster.c
@@ -102,6 +102,7 @@ do_cluster_show(void)
exit(ERR_BAD_CONFIG);
}
+ /* Initialize column headers */
strncpy(headers_show[SHOW_ID].title, _("ID"), MAXLEN);
strncpy(headers_show[SHOW_NAME].title, _("Name"), MAXLEN);
strncpy(headers_show[SHOW_ROLE].title, _("Role"), MAXLEN);
@@ -117,7 +118,20 @@ do_cluster_show(void)
for (i = 0; i < SHOW_HEADER_COUNT; i++)
{
- headers_show[i].max_length = strlen(headers_show[i].title);
+ headers_show[i].display = true;
+
+ if (runtime_options.terse == true)
+ {
+ if (i == SHOW_CONNINFO)
+ {
+ headers_show[i].display = false;
+ }
+ }
+
+ if (headers_show[i].display == true)
+ {
+ headers_show[i].max_length = strlen(headers_show[i].title);
+ }
}
for (cell = nodes.head; cell; cell = cell->next)
@@ -347,6 +361,12 @@ do_cluster_show(void)
for (i = 0; i < SHOW_HEADER_COUNT; i++)
{
+ if (runtime_options.terse == true)
+ {
+ if (headers_show[i].display == false)
+ continue;
+ }
+
if (headers_show[i].cur_length > headers_show[i].max_length)
{
headers_show[i].max_length = headers_show[i].cur_length;
@@ -398,7 +418,13 @@ do_cluster_show(void)
printf("| %-*s ", headers_show[SHOW_STATUS].max_length, cell->node_info->details);
printf("| %-*s ", headers_show[SHOW_UPSTREAM_NAME].max_length, cell->node_info->upstream_node_name);
printf("| %-*s ", headers_show[SHOW_LOCATION].max_length, cell->node_info->location);
- printf("| %-*s\n", headers_show[SHOW_CONNINFO].max_length, cell->node_info->conninfo);
+
+ if (headers_show[SHOW_CONNINFO].display == true)
+ {
+ printf("| %-*s", headers_show[SHOW_CONNINFO].max_length, cell->node_info->conninfo);
+ }
+
+ puts("");
}
}
diff --git a/repmgr-action-daemon.c b/repmgr-action-daemon.c
index a6351df0..cb2aee4b 100644
--- a/repmgr-action-daemon.c
+++ b/repmgr-action-daemon.c
@@ -91,6 +91,7 @@ do_daemon_status(void)
for (i = 0; i < STATUS_HEADER_COUNT; i++)
{
headers_status[i].max_length = strlen(headers_status[i].title);
+ headers_status[i].display = true;
}
i = 0;
diff --git a/repmgr-client-global.h b/repmgr-client-global.h
index d2a4aa65..0686105f 100644
--- a/repmgr-client-global.h
+++ b/repmgr-client-global.h
@@ -199,6 +199,7 @@ typedef struct ColHeader
char title[MAXLEN];
int max_length;
int cur_length;
+ bool display;
} ColHeader;
diff --git a/repmgr-client.c b/repmgr-client.c
index d5546f50..b34b7987 100644
--- a/repmgr-client.c
+++ b/repmgr-client.c
@@ -1947,9 +1947,20 @@ void
print_status_header(int cols, ColHeader *headers)
{
int i;
+ int max_cols = 0;
+
+ /* count how many columns we actually need to display */
+ for (i = 0; i < cols; i++)
+ {
+ if (headers[i].display == true)
+ max_cols ++;
+ }
for (i = 0; i < cols; i++)
{
+ if (headers[i].display == false)
+ continue;
+
if (i == 0)
printf(" ");
else
@@ -1959,17 +1970,22 @@ print_status_header(int cols, ColHeader *headers)
headers[i].max_length,
headers[i].title);
}
+
+
printf("\n");
printf("-");
- for (i = 0; i < cols; i++)
+ for (i = 0; i < max_cols; i++)
{
int j;
+ if (headers[i].display == false)
+ continue;
+
for (j = 0; j < headers[i].max_length; j++)
printf("-");
- if (i < (cols - 1))
+ if (i < (max_cols - 1))
printf("-+-");
else
printf("-");