From 9e10d85538d1fbf43e99b44e5acb45a88ecd9768 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 27 Apr 2020 06:23:26 +0200 Subject: [PATCH] src/api/cli/text_table.rs - format_object: skip optional properties without data --- proxmox/src/api/cli/text_table.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/proxmox/src/api/cli/text_table.rs b/proxmox/src/api/cli/text_table.rs index 51ed2c6b..60498961 100644 --- a/proxmox/src/api/cli/text_table.rs +++ b/proxmox/src/api/cli/text_table.rs @@ -597,7 +597,7 @@ fn format_object( let mut all_right_aligned = true; for name in properties_to_print.iter() { - let (_optional, prop_schema) = match schema.lookup(name) { + let (optional, prop_schema) = match schema.lookup(name) { Some(tup) => tup, None => bail!("property {} does not exist in schema.", name), }; @@ -615,6 +615,12 @@ fn format_object( if !right_align { all_right_aligned = false; } + if optional { + if let Some(object) = data.as_object() { + if object.get(name).is_none() { continue; } + } + } + let header_width = header.chars().count(); if header_width > max_name_width { max_name_width = header_width; }