mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-29 17:15:57 +00:00
src/api/cli/text_table.rs - format_object: skip optional properties without data
This commit is contained in:
parent
e229c3d582
commit
9e10d85538
@ -597,7 +597,7 @@ fn format_object<W: Write>(
|
||||
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<W: Write>(
|
||||
|
||||
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; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user