From: Dietmar Maurer Date: Fri, 29 Jun 2018 11:15:17 +0000 (+0200) Subject: cli: print_api_result: use print_api_list to print objects X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=2a174d2ab092e7b8fcf0e40ab04d1f0f19be58ad cli: print_api_result: use print_api_list to print objects In order to draw the new asciiart border ... Signed-off-by: Dietmar Maurer --- diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm index b55861a..80504b2 100644 --- a/src/PVE/CLIFormatter.pm +++ b/src/PVE/CLIFormatter.pm @@ -143,9 +143,12 @@ sub print_api_result { my $type = $result_schema->{type}; if ($type eq 'object') { $props_to_print = [ sort keys %$data ] if !defined($props_to_print); + my $kvstore = []; foreach my $key (@$props_to_print) { - print $key . ": " . data_to_text($data->{$key}) . "\n"; + push @$kvstore, { key => $key, value => data_to_text($data->{$key}) }; } + my $schema = { type => 'array', items => { type => 'object' }}; + print_api_list($kvstore, $schema, ['key', 'value'], 0, $format eq 'text'); } elsif ($type eq 'array') { return if !scalar(@$data); my $item_type = $result_schema->{items}->{type};