]> git.proxmox.com Git - pve-common.git/commitdiff
PVE::CLIFormatter::print_api_result - use print_api_list to print arrays
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 5 Jul 2018 07:26:27 +0000 (09:26 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 5 Jul 2018 16:33:25 +0000 (18:33 +0200)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
src/PVE/CLIFormatter.pm

index 052ed6d53282fea9a8637a12419028e031af9870..08907fb5077229aee20d4f05483d5f196f7f4def 100644 (file)
@@ -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");