]> git.proxmox.com Git - pve-common.git/commitdiff
cli: print_api_result: simplify props_to_print code
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 26 Jun 2018 13:55:26 +0000 (15:55 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 27 Jun 2018 09:00:55 +0000 (11:00 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/CLIHandler.pm

index 3013cc213dd2069365a67391c1b2a5f3b9a2c5cc..414caa5d8c25ee4835ef7d1756e69fa98a2f144e 100644 (file)
@@ -551,14 +551,9 @@ sub print_api_result {
     } elsif ($format eq 'text') {
        my $type = $result_schema->{type};
        if ($type eq 'object') {
     } elsif ($format eq 'text') {
        my $type = $result_schema->{type};
        if ($type eq 'object') {
-           if (defined($props_to_print)) {
-               foreach my $key (@$props_to_print) {
-                   print $key . ": " .  data_to_text($data->{$key}) . "\n";
-               }
-           } else {
-               foreach my $key (sort keys %$data) {
-                   print $key . ": " .  data_to_text($data->{$key}) . "\n";
-               }
+           $props_to_print = [ sort keys %$data ] if !defined($props_to_print);
+           foreach my $key (@$props_to_print) {
+               print $key . ": " .  data_to_text($data->{$key}) . "\n";
            }
        } elsif ($type eq 'array') {
            return if !scalar(@$data);
            }
        } elsif ($type eq 'array') {
            return if !scalar(@$data);