diff --git a/clients/cli/utils.c b/clients/cli/utils.c index 064343a151..97add019b7 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -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) { diff --git a/clients/tests/test-client.check-on-disk/test_001.expected b/clients/tests/test-client.check-on-disk/test_001.expected index 0fd48391bc..17f9d76031 100644 --- a/clients/tests/test-client.check-on-disk/test_001.expected +++ b/clients/tests/test-client.check-on-disk/test_001.expected @@ -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