From: Thomas Lamprecht Date: Tue, 26 Jun 2018 13:55:26 +0000 (+0200) Subject: cli: print_api_result: simplify props_to_print code X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=fa7d20bf9fe64ac413f6882b978aa5380734cb7f cli: print_api_result: simplify props_to_print code Signed-off-by: Thomas Lamprecht --- diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm index 3013cc2..414caa5 100644 --- a/src/PVE/CLIHandler.pm +++ b/src/PVE/CLIHandler.pm @@ -551,14 +551,9 @@ sub print_api_result { } 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);