5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2025-01-10 09:17:37 +03:00

introcude new output format 'yaml'

This commit is contained in:
Dietmar Maurer 2018-07-26 12:02:45 +02:00
parent b01a09e73f
commit ac6c61bf13
2 changed files with 4 additions and 2 deletions

View File

@ -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') {

View File

@ -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',
});