]> git.proxmox.com Git - pve-client.git/commitdiff
use new PVE::APIClient::CLIHandler::print_api_result
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 22 Jun 2018 07:54:21 +0000 (09:54 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 25 Jun 2018 10:13:38 +0000 (12:13 +0200)
PVE/APIClient/Helpers.pm
pveclient

index 9ee00e9d127bcdc17308bc4964141adb10430840..ed1822d4a514dea06b3807c6c9feab7097d7fd50 100644 (file)
@@ -41,40 +41,6 @@ sub get_output_format {
     return $client_output_format;
 }
 
     return $client_output_format;
 }
 
-sub print_result {
-    my ($data, $result_schema) = @_;
-
-    my $format = get_output_format();
-
-    return if $result_schema->{type} eq 'null';
-
-    # TODO: implement different output formats ($format)
-
-    if ($format eq 'json') {
-       print to_json($data, {utf8 => 1, allow_nonref => 1, canonical => 1, pretty => 1 });
-    } elsif ($format eq 'text') {
-       my $type = $result_schema->{type};
-       if ($type eq 'object') {
-           die "implement me";
-       } elsif ($type eq 'array') {
-           my $item_type = $result_schema->{items}->{type};
-           if ($item_type eq 'object') {
-               die "implement me";
-           } elsif ($item_type eq 'array') {
-               die "implement me";
-           } else {
-               foreach my $el (@$data) {
-                   print "$el\n"
-               }
-           }
-       } else {
-           print "$data\n";
-       }
-    } else {
-       die "internal error: unknown output format"; # should not happen
-    }
-}
-
 my $__real_remove_formats; $__real_remove_formats = sub {
     my ($properties) = @_;
 
 my $__real_remove_formats; $__real_remove_formats = sub {
     my ($properties) = @_;
 
index 2995fd5441e732bcf451828d7dca6f3b2cbde816..7688ffe7670cc335d25676280724bf519aa76b69 100755 (executable)
--- a/pveclient
+++ b/pveclient
@@ -108,7 +108,8 @@ $path_properties->{api_path} = {
 my $format_result = sub {
     my ($data) = @_;
 
 my $format_result = sub {
     my ($data) = @_;
 
-    PVE::APIClient::Helpers::print_result($data, $path_returns);
+    my $format = PVE::APIClient::Helpers::get_output_format();
+    PVE::APIClient::CLIHandler::print_api_result($format, $data, $path_returns);
 };
 
 __PACKAGE__->register_method ({
 };
 
 __PACKAGE__->register_method ({