From c850b99883acc67ee63728c73b5bf5cac082f8a7 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 5 Jul 2018 09:26:27 +0200 Subject: [PATCH] PVE::CLIFormatter::print_api_result - use print_api_list to print arrays Signed-off-by: Dietmar Maurer --- src/PVE/CLIFormatter.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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"); -- 2.39.2