cli: fix skipping columns with all default-values

The header-cell is the header for a column with possibly many
rows.

We must not set:
  header_cell->skip = nmc_config->overview && is_default;
for a particular cell, because it does not take into accound
the neighbouring rows. It is only correct, if there is only
one row.

Invert the logical meaning and rename "strip" to "to_print".
Each cell then can opt-in, whether it needs to be printed.
Only if no cell opts-in, it will be skipped.

Fixes: 9a19bbcb2f
This commit is contained in:
Thomas Haller 2018-06-08 13:35:58 +02:00
parent e0570ae8d6
commit 9c51ebc298
2 changed files with 18 additions and 10 deletions

View file

@ -896,7 +896,11 @@ typedef struct {
const PrintDataCol *col;
const char *title;
bool title_to_free:1;
bool skip:1;
/* whether the column should be printed. If not %TRUE,
* the column will be skipped. */
bool to_print:1;
int width;
} PrintDataHeaderCell;
@ -995,7 +999,10 @@ _print_fill (const NmcConfig *nmc_config,
header_cell->col_idx = col_idx;
header_cell->col = col;
header_cell->skip = FALSE;
/* by default, the entire column is skipped. That is the case,
* unless we have a cell (below) which opts-in to be printed. */
header_cell->to_print = FALSE;
header_cell->title = nm_meta_abstract_info_get_name (info, TRUE);
if ( nmc_config->multiline_output
@ -1053,7 +1060,8 @@ _print_fill (const NmcConfig *nmc_config,
nm_assert (!to_free || value == to_free);
header_cell->skip = nmc_config->overview && is_default;
if (!nmc_config->overview || !is_default)
header_cell->to_print = TRUE;
if (NM_FLAGS_HAS (text_out_flags, NM_META_ACCESSOR_GET_OUT_FLAGS_STRV)) {
if (nmc_config->multiline_output) {
@ -1137,7 +1145,7 @@ _print_skip_column (const NmcConfig *nmc_config,
selection_item = header_cell->col->selection_item;
info = selection_item->info;
if (header_cell->skip)
if (!header_cell->to_print)
return TRUE;
if (nmc_config->multiline_output) {

View file

@ -52,24 +52,24 @@ stderr: 49 bytes
Błąd: Nie odnaleziono urządzenia „wlan0”.
<<<
size: 146
size: 120
location: clients/tests/test-client.py:831:test_001()/5
cmd: $NMCLI c s
lang: C
returncode: 0
stdout: 26 bytes
stdout: 1 bytes
>>>
NAME UUID TYPE DEVICE
<<<
size: 156
size: 130
location: clients/tests/test-client.py:831:test_001()/6
cmd: $NMCLI c s
lang: pl_PL.UTF-8
returncode: 0
stdout: 26 bytes
stdout: 1 bytes
>>>
NAME UUID TYPE DEVICE
<<<
size: 192