cli: data_to_text: never render undefined values

To make it visible when the API return undefined values.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2018-06-29 13:15:25 +02:00 committed by Thomas Lamprecht
parent 4ac8500023
commit 3cd6f2f350

View File

@ -42,6 +42,8 @@ sub println_max {
sub data_to_text {
my ($data, $propdef) = @_;
return '' if !defined($data);
if (defined($propdef)) {
if (my $type = $propdef->{type}) {
if ($type eq 'boolean') {
@ -57,7 +59,6 @@ sub data_to_text {
return $code->($data);
}
}
return '' if !defined($data);
if (my $class = ref($data)) {
return to_json($data, { canonical => 1 });