repmgr: add --terse mode to "cluster show"

This suppresses display of the usually lengthy "conninfo" column, mainly
useful for generating a compact table suitable for pasting into emails,
chats etc. without messy line breaks.

Implements GitHub #521.
This commit is contained in:
Ian Barwick
2019-01-09 10:05:21 +09:00
parent 3389491151
commit c66c8ebc98
7 changed files with 68 additions and 4 deletions

View File

@@ -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("-");