From ac6c61bf135f4e0bb261c4b95cec2071677da99e Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 26 Jul 2018 12:02:45 +0200 Subject: [PATCH] introcude new output format 'yaml' --- 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.39.2