From: Dietmar Maurer Date: Thu, 5 Jul 2018 07:26:27 +0000 (+0200) Subject: PVE::CLIFormatter::print_api_result - use print_api_list to print arrays X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=c850b99883acc67ee63728c73b5bf5cac082f8a7 PVE::CLIFormatter::print_api_result - use print_api_list to print arrays Signed-off-by: Dietmar Maurer --- diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm index 052ed6d..08907fb 100644 --- a/src/PVE/CLIFormatter.pm +++ b/src/PVE/CLIFormatter.pm @@ -384,14 +384,17 @@ sub print_api_result { print_api_list($kvstore, $schema, ['key', 'value'], $options); } elsif ($type eq 'array') { return if !scalar(@$data); + $options->{border} = $format eq 'text'; my $item_type = $result_schema->{items}->{type}; if ($item_type eq 'object') { - $options->{border} = $format eq 'text'; print_api_list($data, $result_schema, $props_to_print, $options); } else { - foreach my $entry (@$data) { - print encode($encoding, data_to_text($entry, $result_schema->{items}, $options) . "\n"); + my $kvstore = []; + foreach my $value (@$data) { + push @$kvstore, { value => $value }; } + my $schema = { type => 'array', items => { type => 'object', properties => { value => $result_schema->{items} }}}; + print_api_list($kvstore, $schema, ['value'], $options); } } else { print encode($encoding, "$data\n");