[pve-devel] applied: [pve-manager 1/2] pvesh - remove interactive readline mode

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Jul 11 10:54:58 CEST 2018


applied both patches with a fixup for the changes in pve-common:

--->8---
>From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Wolfgang Bumiller <w.bumiller at proxmox.com>
Date: Wed, 11 Jul 2018 10:48:45 +0200
Subject: [PATCH manager] fixup pvesh for changes in pve-common

In pve-common the following changes happened:
  0adee98 ("cli_handler: pass common output options as separate parameter")
  352b7a1 ("PVE::CLIFormatter - implement new output options")
We now get the format passed via an options hash in the
output function instead of seeing it as an api call
parameter.

Similarly, --quiet is now already handled there.

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 bin/pvesh | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/bin/pvesh b/bin/pvesh
index d3ab9954..a5a9b9fb 100755
--- a/bin/pvesh
+++ b/bin/pvesh
@@ -1,8 +1,9 @@
 #!/usr/bin/perl
 
+package pvesh;
+
 use strict;
 use warnings;
-use Data::Dumper;
 use HTTP::Status qw(:constants :is status_message);
 use String::ShellQuote;
 use PVE::JSONSchema qw(get_standard_option);
@@ -19,8 +20,6 @@ use JSON;
 
 use base qw(PVE::CLIHandler);
 
-my $output_format = 'text';
-
 my $disable_proxy = 0;
 my $opt_nooutput = 0;
 
@@ -237,13 +236,11 @@ $path_properties->{quiet} = {
 };
 
 my $format_result = sub {
-    my ($data) = @_;
-
-    return if $opt_nooutput || $output_format eq 'none';
+    my ($data, $result_schema, $options) = @_;
 
-    my $options = PVE::CLIFormatter::query_terminal_options({});
+    return if $opt_nooutput || ($options->{format}//'') eq 'none';
 
-    PVE::CLIFormatter::print_api_result($output_format, $data, $path_returns, undef, $options);
+    PVE::CLIFormatter::print_api_result($data, $path_returns, undef, $options);
 };
 
 sub call_api_method {
@@ -254,12 +251,6 @@ sub call_api_method {
     my $path = PVE::Tools::extract_param($param, 'api_path');
     die "missing API path\n" if !defined($path);
 
-    if (my $format = PVE::Tools::extract_param($param, 'format'))  {
-	$output_format = $format;
-    }
-
-    $opt_nooutput = 1 if PVE::Tools::extract_param($param, 'quiet');
-
     my $uri_param = {};
     my ($handler, $info) = PVE::API2->find_handler($method, $path, $uri_param);
     if (!$handler || !$info) {
-- 
2.11.0





More information about the pve-devel mailing list