]> git.proxmox.com Git - pve-common.git/commitdiff
cli: print_api_result: use print_api_list to print objects
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 29 Jun 2018 11:15:17 +0000 (13:15 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 29 Jun 2018 12:39:48 +0000 (14:39 +0200)
In order to draw the new asciiart border ...

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
src/PVE/CLIFormatter.pm

index b55861a1101cab7012f37d097b541b320b96cd79..80504b26a9249e3113733ab550a462b8df6a9297 100644 (file)
@@ -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};