]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/CLIFormatter.pm
cli: data_to_text: never render undefined values
[pve-common.git] / src / PVE / CLIFormatter.pm
index cbe63907241c378dff6e78d4bf201455ccb94829..a6c47952fecf16b8d852c2ac1a6b579c836ec262 100644 (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 });