[pve-devel] applied: [pve-common 7/7] introcude new output format 'yaml'

Dietmar Maurer dietmar at proxmox.com
Thu Jul 26 13:04:48 CEST 2018


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 src/PVE/CLIFormatter.pm | 4 +++-
 src/PVE/JSONSchema.pm   | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm
index 61b313b..f6ad459 100644
--- a/src/PVE/CLIFormatter.pm
+++ b/src/PVE/CLIFormatter.pm
@@ -389,7 +389,9 @@ sub print_api_result {
 
     return if $result_schema->{type} eq 'null';
 
-    if ($format eq 'json') {
+    if ($format eq 'yaml') {
+	print encode('UTF-8', CPAN::Meta::YAML::Dump($data));
+    } elsif ($format eq 'json') {
 	# Note: we always use utf8 encoding for json format
 	print to_json($data, {utf8 => 1, allow_nonref => 1, canonical => 1 }) . "\n";
     } elsif ($format eq 'json-pretty') {
diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index c9a9b1e..06c500f 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -108,7 +108,7 @@ register_standard_option('fingerprint-sha256', {
 register_standard_option('pve-output-format', {
     type => 'string',
     description => 'Output format.',
-    enum => [ 'text', 'json', 'json-pretty' ],
+    enum => [ 'text', 'json', 'json-pretty', 'yaml' ],
     optional => 1,
     default => 'text',
 });
-- 
2.11.0




More information about the pve-devel mailing list