mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-15 01:01:52 +00:00
introcude new output format 'yaml'
This commit is contained in:
parent
b01a09e73f
commit
ac6c61bf13
@ -389,7 +389,9 @@ sub print_api_result {
|
|||||||
|
|
||||||
return if $result_schema->{type} eq 'null';
|
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
|
# Note: we always use utf8 encoding for json format
|
||||||
print to_json($data, {utf8 => 1, allow_nonref => 1, canonical => 1 }) . "\n";
|
print to_json($data, {utf8 => 1, allow_nonref => 1, canonical => 1 }) . "\n";
|
||||||
} elsif ($format eq 'json-pretty') {
|
} elsif ($format eq 'json-pretty') {
|
||||||
|
@ -108,7 +108,7 @@ register_standard_option('fingerprint-sha256', {
|
|||||||
register_standard_option('pve-output-format', {
|
register_standard_option('pve-output-format', {
|
||||||
type => 'string',
|
type => 'string',
|
||||||
description => 'Output format.',
|
description => 'Output format.',
|
||||||
enum => [ 'text', 'json', 'json-pretty' ],
|
enum => [ 'text', 'json', 'json-pretty', 'yaml' ],
|
||||||
optional => 1,
|
optional => 1,
|
||||||
default => 'text',
|
default => 'text',
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user