5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-22 21:33:47 +03:00

output format options: remove 'plain', add 'json-pretty'

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2018-07-10 13:51:27 +02:00 committed by Thomas Lamprecht
parent f0bcf4d4c6
commit cd6591d38b
2 changed files with 5 additions and 2 deletions

View File

@ -379,9 +379,12 @@ 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 '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') {
# 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, pretty => 1 }); print to_json($data, {utf8 => 1, allow_nonref => 1, canonical => 1, pretty => 1 });
} elsif ($format eq 'text' || $format eq 'plain') { } elsif ($format eq 'text') {
my $encoding = $options->{encoding} // 'UTF-8'; my $encoding = $options->{encoding} // 'UTF-8';
my $type = $result_schema->{type}; my $type = $result_schema->{type};
if ($type eq 'object') { if ($type eq 'object') {

View File

@ -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', 'plain', 'json' ], enum => [ 'text', 'json', 'json-pretty' ],
optional => 1, optional => 1,
default => 'text', default => 'text',
}); });