summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-06-08 13:35:58 +0200
committerThomas Haller <thaller@redhat.com>2018-07-25 17:08:37 +0200
commit9c51ebc298cb01dac6b2abf882a62026443bfa09 (patch)
tree4198a5931b36e43011251ce0c7e9b3779dd85b12
parente0570ae8d679542152931640b05c4762d66875fe (diff)
downloadNetworkManager-9c51ebc298cb01dac6b2abf882a62026443bfa09.tar.gz
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: 9a19bbcb2f6b78be2541334a0d650e765a11fa2b
-rw-r--r--clients/cli/utils.c16
-rw-r--r--clients/tests/test-client.check-on-disk/test_001.expected12
2 files changed, 18 insertions, 10 deletions
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